{"id":17983512,"url":"https://github.com/techjacker/slackops","last_synced_at":"2025-04-04T02:12:55.841Z","repository":{"id":141452481,"uuid":"385343680","full_name":"techjacker/slackops","owner":"techjacker","description":"K8 operator that ensures slack mirrors the state of the world in a given cluster","archived":false,"fork":false,"pushed_at":"2021-07-18T14:12:57.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T13:36:58.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techjacker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-12T18:21:11.000Z","updated_at":"2021-07-18T14:12:59.000Z","dependencies_parsed_at":"2024-06-20T20:12:12.590Z","dependency_job_id":"1f8fb0b0-23f8-434d-8577-369b5d580614","html_url":"https://github.com/techjacker/slackops","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fslackops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fslackops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fslackops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fslackops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techjacker","download_url":"https://codeload.github.com/techjacker/slackops/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107828,"owners_count":20884797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T18:17:27.851Z","updated_at":"2025-04-04T02:12:55.816Z","avatar_url":"https://github.com/techjacker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build](https://github.com/techjacker/slackops/actions/workflows/build.yml/badge.svg)](https://github.com/techjacker/slackops/actions/workflows/build.yml)\n# Slackops\nK8 operator that ensures slack mirrors the state of the world in a given kubernetes cluster. Who needs gitops when you can have slackops?\n\n## Quickstart\n### Deploy\n\n### Deploy Operator\n```shell\nkubectl apply -f templates-exports\n```\n#### Create K8 ConfigMap\nUpdate the [configmap](fixtures/configmap.yaml) with desired values.\n```shell\nkubectl apply -f fixtures/configmap.yaml\n```\n#### Deploy K8 slack bot secret\nFollow the [slack setup guide below](#slack-setup) and set `$SLACK_BOT_TOKEN` in your environment. Then run:\n```shell\nexport K8_OP_NS=slackops-system\nkubectl -n \"$K8_OP_NS\" create secret generic slackops \\\n  --from-literal=slack_bot_token=\"$SLACK_BOT_TOKEN\"\n```\n### Check Operator Working\n```shell\nexport K8_OP_NS=slackops-system\nkubectl config set-context --current --namespace=${K8_OP_NS}\nkubectl logs -c manager slackops-controller-manager-xxxx\n```\n### Test\nEnsure the pod name you create contains the string specified in the configmap you deloyed (eg `pod_target_contains: \"foo\"`).\n```shell\n# triggers create\nkubectl run nginx-foo --image=nginx --restart=Never\n# triggers update (only works for label updates currently)\nkubectl patch pod nginx-foo --patch \"$(cat fixtures/patch.yaml)\"\n# tiggers delete\nkubectl delete pod nginx-foo\n# tiggers nothing because does not have \"foo\" in the name\nkubectl run nginx-blah --image=nginx --restart=Never\n```\n### Remove Operator\n```shell\nkubectl delete -f templates-exports\n```\n---------------------------------------------------------\n## Slack Setup\n### Slack App and Token Creation\n1. [Create a slack app](https://api.slack.com/start/overview#creating) in your slack workspace\n2. [Request the needed permissions and generate a token for the app](https://api.slack.com/messaging/sending#permissions) which are\n   1. `chat:write.public`\n   2. `chat:write`\n3. Generate an OAuth token for the app via the OAuth \u0026 Permissions settings page (you'll need to add this as a k8 secret in the operator namespace)\n4. (Re-)Install the app after you've added the permissions so they are applied to your workspace\n\n### Testing token works\nCheck that you have granted all required permissions by making a test call via `curl`.\nExample assumes:\n- you have a public channel named `random` in your slack workspace\n- you have set the OAuth token as the `SLACK_BOT_TOKEN`  environment variable in your shell\n```shell\n$ curl -XPOST -H \"Authorization: Bearer $SLACK_BOT_TOKEN\" -H \"Content-type: application/json\" -d '{\n  \"channel\": \"random\",\n  \"text\": \"Hello world :tada:\"\n}' 'https://slack.com/api/chat.postMessage'\n```\n\n---------------------------------------------------------\n\n### Security\n- [x] Container security scan (see [build](.github/workflows/build.yml))\n- [x] Does not run as root (see [deployment](config/manager/manager.yaml))\n\n---------------------------------------------------------\n## Local Development\n### Install dependencies\n```\nmake deps-lint\npip install pre-commit\npre-commit install\npre-commit install-hooks\n```\n### Setup of new API\n```shell\n$ operator-sdk init --domain=techjacker.com --owner \"Andrew Griffiths\" --repo github.com/techjacker/slackops\n$ operator-sdk create api --group=core --version=v1 --kind=Pod --controller=true --resource=false\n```\n### Running app locally\nCreate a .`env` file and populate with the env vars listed in `.env.example`.\n```shell\nsource .env.example\nsource .env\nmake install\n# ensure you have a valid kubeconfig set before running\nmake run\n# need to manually created the slackops-system namespace before can test by creating/deleting pods\n```\n### Build Docker Image\n```\nsource .env.example\nsource .env\necho $DOCKERHUB_PWD | docker login --username $DOCKERHUB_ID --password-stdin\nmake docker-build\nmake docker-push\n```\n\n### Deploy to k8\n```shell\n#### Create secrets\nexport K8_OP_NS=slackops-system\nkubectl -n \"$K8_OP_NS\" create secret generic slackops \\\n  --from-literal=slack_bot_token=\"$SLACK_BOT_TOKEN\"\n#### Create ConfigMap\nkubectl apply -f fixtures/configmap.yaml\n### Deploy Operator option #1\nmake deploy\n### Deploy Operator option #2\nmake deploy-export\nkubectl apply -f templates-exports\n#### check it worked\nexport K8_OP_NS=slackops-system\nkubectl config set-context --current --namespace=${K8_OP_NS}\nkubectl logs -c manager slackops-controller-manager-56895df697-9tz67\n### Delete Operator\nmake undeploy\n```\n\n--------------------------------\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fslackops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechjacker%2Fslackops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fslackops/lists"}