Slack integration for tracking new releases of GitHub repositories for kubernetes
Slack is very popular for communication in tech companies. GitHub provides http api for developers, with endpoints for different information. This app is a Slack integration, that sends alerts when there is a new release on one of the repositories that are being tracked.
The application is designed to run with Kubernetes. The main deployment file is a cronjob for Kubernetes, and there is a second environment with docker-compose file, intended for trial and testing purpose only.
Docker-compose test environment
The docker-compose file, is a test environment. It starts up its own etcd, because the app relies on etcd for storing the latest versions found. To run this environment, there is an .env file that has to be edited.
Environment variables:
SLACK_HOOK=insert_slack_hook
SLACK_CHANNEL=#change-to-your-slack
ETCD_HOST=etcd1 # etcd hostname
ETCD_PORT=2379 # Change to etcd port
To obtain the slack hook, you can go to your domains settings for custom integrations, which you can find on *.slack.com/apps/manage/custom-integrations (change * to your domain), and change the insert_slack_hook to your hook url, the channel to which you want the alerts to be posted. The defaults for ETCD hostname and port are connected to the docker-compose etcd cluster.
Run the docker compose environment with: docker-compose up.
Kubernetes environment
The app is a one time run only, and returns a success code. You can run the docker compose file on your own to check it, or schedule the running with cron, but for production the Kubernetes deployment file is recommended.
The kubernetes cronjob deployment is set to run with daily crontab. Edit the env variables in the version-check-crontab.yml file, like the ones in the docker-compose file above.
Then create a namespace for the deployment, the one used by default is called version-check.
Quick reference:
To create a namespace, run: kubectl create namespace NAME
Run the cronjob with: kubectl create -f ./version-check-cronjob.yaml
To update the cronjob after updates, run kubectl replace -f ./version-check-cronjob.yaml