Botkube + Kubernetes










It was a long day for me that day in the office …

One of the new projects came in and the application was to be deployed on a Kubernetes cluster and it took us a month of brainstorming Finally we came up with an application design that suited the customer requirement.

We decided to go with EKS (Elastic Kubernetes service by AWS), everything went well but one thing was still missing …

We wanted something that will:

  • Give us information about what is going on in the cluster

  • Give us insights about what does the cluster consist of, which pods are getting terminated, which pods are being created and are there any errors popping up?

  • Is there any way that will give us error messages as well?

  • Can it provide a single point from where we can run kubectl commands to get information about the cluster?

  • Last but not the least, what is it that can be integrated with some popular messenger like slack as this one is being used in my office.


And what if all can be provided FREE OF COST 😊

After thorough research we found a solution for all the requirements which was BOTKUBE and this is the subject of this article.


What is Botkube?


Botkube is a messaging bot for monitoring and debugging Kubernetes clusters. It's built and maintained with lots of effort & love by Infra Cloud.

Beauty of Botkube lies in the fact that it runs as an integral part on your kubernetes cluster and it is independent of kubernetes platform you are running on. Whether kubernetes is hosted on cloud or on bare-metal, it actually doesn't make any difference at all.




Features




Now let's deep dive into how Botkube works.For this we assume that we already have a kubernetes cluster up and running.


Here we are going to configure Botkube to send the alerts to the Slack channel following below steps:

  • Sign up to slack Click here

  • Follow the mentioned procedure to create a workspace on slack and then create a channel where we can configure Botkube to send messages.




  • Now we will add Botkube app to our slack channel.




  • In the next step , Botkube will give an authentication token, copy it and keep it safe as this is slack account specific. If once lost cannot be regenerated.



Now once the Botkube app is installed on the slack workspace, we need to add this app in to our slack channel where we want to get the notifications.



Ok now we are half way down the road ...


  • Now let’s go back to our Kubernetes cluster. to install Botkube and execute the below command.

[root@test-node ~]# helm repo add infracloudio https://infracloudio.github.io/charts
"infracloudio" has been added to your repositories
[root@test-node ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "infracloudio" chart repository
Update Complete. ⎈ Happy Helming!

  • Execute the below command and change the values as per your environment.



  • Now let's create a separate namespace to install Botkube

kubectl create ns botkube
  • Finally install Botkube


[root@test-node ~]# kubectl create ns botkube
namespace/botkube created
[root@test-node ~]# helm install --version v0.10.0 botkube --namespace botkube --set communications.slack.enabled=true --set communications.slack.channel=botkube-k8-notifications --set communications.slack.token=xoxb-1242661797206-1248028645157-Udvz5Rg3uhCQgE80FJXc1wpW --set config.settings.clustername=terraform-eks-demo --set config.settings.allowkubectl=true --set image.repository=infracloudio/botkube --set image.tag=v0.10.0 infracloudio/botkube
NAME: botkube
LAST DEPLOYED: Sat Jul 18 19:40:50 2020
NAMESPACE: botkube
STATUS: deployed
REVISION: 1
TEST SUITE: None
[root@test-node ~]#
 

  • We will see that Botkube pod is up and running

[root@test-node ~]# kubectl get pods -n botkube
NAME READY STATUS RESTARTS AGE
botkube-b77b8ccdf-rtsln 1/1 Running 0 2m45s
[root@test-node ~]#
  • Now lets go back to slack channel and see the Botkube in action.



See how beautiful it is and how seamlessly it is allowing us to execute read-only command.

Let's see what happens when we try to execute a write level command.Here we will try to create a namespace.



It will not allow us to do so , by default it gives access to read only commands.

This feature is allowing us to manually get details about the cluster from slack channel itself, SAVE TIME , NO NEED TO LOGIN TO THE CLUSTER !!!!

Secondly it not only allows us to run kubectl commands but also sends us notification when something happens in the cluster.

Let's delete a pod in our cluster.

We will now execute below command in our cluster

[root@test-node ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
frontend-6cb7f8bd65-9xsjc 1/1 Running 0 123m
frontend-6cb7f8bd65-dg6sv 1/1 Running 0 123m
frontend-6cb7f8bd65-sp72q 1/1 Running 0 123m
redis-master-7db7f6579f-n6lsm 1/1 Running 0 124m
redis-slave-7664787fbc-b975x 1/1 Running 0 124m
redis-slave-7664787fbc-pp6h2 1/1 Running 0 124m
[root@test-node ~]# kubectl delete pod redis-slave-7664787fbc-pp6h2
pod "redis-slave-7664787fbc-pp6h2" deleted
 
Corresponding to this command, botkube sent us notification like below 
to our slack channel.


Botkube by default sends notification for each and every event but it can be customized for sure.

  • Edit the helm chart code directly.

  • Edit the config map related to Botkube


So we saw that it's really easy to set-up the Botkube. Tts like a cakewalk and in return it gives us in insight of our cluster free of cost .

I personally liked it and so thought of writing about it.

It’s highly recommended from my side. Do give it a shot , trust me you will love it 😊


Credits: Botkube Team

Detailed documentation : botkube.io

Infracloud Technologies: infracloud.io



497 views1 comment

Recent Posts

See All
 

Subscribe Form

©2020 by Linux Advise