Kubernetes Slack Notification Cron Job POC
https://hub.docker.com/r/mpatters72/kube-cron-slack/
https://my.slack.com/services/new/incoming-webhook
cp templates/kube-cron-slack-secret.yaml /tmp/
https://kubernetes.io/docs/concepts/configuration/secret/#creating-a-secret-manually
- Use the webhook URI you generated here and your desired slack channel
echo -n 'https://hooks.slack.com/services/UseYour/RealChannel/URIHERE' | base64
aHR0cHM6Ly9ob29rcy5zbGFjay5jb20vc2VydmljZXMvVXNlWW91ci9SZWFsQ2hhbm5lbC9VUklIRVJF
echo -n '#my-slack-channel' | base64
I215LXNsYWNrLWNoYW5uZWw=
kubectl apply -f /tmp/kube-cron-slack-secret.yaml
Verify
kubectl get secret kube-cron-slack -o yaml
-
e.g. do you really want this running every 2 minutes?
-
See: https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/
-
Also note we are exposing secret and pod info to pod:
cp templates/kube-cron-slack-cronjob.yaml /tmp
# make any edits to /tmp/kube-cron-slack-cronjob.yaml
# apply it
kubectl apply -f /tmp/kube-cron-slack-cronjob.yaml
kubectl get cronjob
kubectl get jobs --watch