An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
Notify kubernetes events with botkube
At Cisco we use Webex as our IM collaboration engine. It is same as Teams/Slack with communication capabilities. One can build a bot for interaction and use APIs to communicate with webex teams.
As a platform team we want to notify interested parties when events happen like pod creation, deployment rollout, pod errors ...
When exploring around I came across botkube which can help solve our problem to a major extent
Architecture
Source: https://www.botkube.io/architecture/
Modes of usage
- Full fledged chatbot - integrations to Slack, Mattermost and MS Teams
- Sink - to push events, used for datastores like Elasticsearch and webhooks for use-cases
- Custom filters - for validations and recommendations
Install botkube
- Prepare a webhook listener (
<WEBHOOK_URL>
) - Decide on a name for your cluster (any string:
<CLUSTER_NAME>
) - Get and update configuration values
$ wget https://raw.githubusercontent.com/infracloudio/botkube/v0.12.4/helm/botkube/sample-res-config.yaml$ mv sample-res-config.yaml /path/to/config.yaml$ vi /path/to/config.yaml
- Install
$ helm repo add infracloudio https://infracloudio.github.io/charts$ helm repo update$ helm install --version v0.12.4 botkube --namespace botkube \--set communications.webhook.enabled=true \--set communications.webhook.url=<WEBHOOK_URL> \--set config.settings.clustername=<CLUSTER_NAME> \--set image.repository=infracloudio/botkube \--set image.tag=v0.12.4 \-f /path/to/config.yamlinfracloudio/botkube
- Check the installation:
$ kubectl get-all -n botkubeNAME NAMESPACE AGEconfigmap/botkube-configmap botkube 6d22hconfigmap/kube-root-ca.crt botkube 6d22hpod/botkube-785d6c889-srbzg botkube 6d22hsecret/botkube-communication-secret botkube 6d22hsecret/botkube-sa-token-btjvj botkube 6d22hsecret/default-token-d5s9n botkube 6d22hsecret/sh.helm.release.v1.botkube.v1 botkube 6d22hserviceaccount/botkube-sa botkube 6d22hserviceaccount/default botkube 6d22hdeployment.apps/botkube botkube 6d22hreplicaset.apps/botkube-785d6c889 botkube 6d22h
get-all is a krew plugin
Usage
Now when identified events are triggered, webhook url is POST
ed with an appropriate json payload
$ kubectl logs -n botkube pod/botkube-785d6c889-srbzg...INFO[2022-04-09T13:27:26Z] Registering resource lifecycle informerINFO[2022-04-09T13:27:26Z] Adding informer for resource:apps/v1/deploymentsINFO[2022-04-09T13:27:26Z] Adding informer for resource:apps/v1/statefulsetsINFO[2022-04-09T13:27:26Z] Adding informer for resource:apps/v1/daemonsetsINFO[2022-04-09T13:27:26Z] Adding informer for resource:v1/nodesINFO[2022-04-09T13:27:26Z] Registering kubernetes events informer for types: warningINFO[2022-04-09T13:27:26Z] Registering kubernetes events informer for types: normalINFO[2022-04-09T13:27:26Z] Registering watcher on configfile /config/resource_config.yaml
Payloads will be like:
{ "meta": { "cluster": "macbook-kind", "kind": "Deployment", "name": "test-dep4", "namespace": "default" }, "status": { "level": "info", "type": "create" }, "summary": "Deployment *default/test-dep4* has been created in *macbook-kind* cluster
", "timestamp": "2022-04-12T00:38:15Z"}
Conclusion
botkube
is capable of a lot more including building a full-fledged chatbot for managing kubernetes cluster and provides extension points as well. Do check-out the documentation
There is another similar project called kubewatch, but not active anymore
Original Link: https://dev.to/ashokan/notify-kubernetes-events-with-botkube-4896
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To