Effortless EKS Monitoring with ChatOps using Botkube
ChatOps allows us to operate DevOps tools using chat clients. Implementing ChatOps with EKS is painless using BotKube. This tool lets us monitor and debug our K8S cluster. The app integrates with Slack, Teams, etc. So, for example, we could view our K8S deployments with a simple command on Slack or view logs in real-time. Also, give us recommendations for standard practice, such avoid using the latest containers image versions.
This updated version revisits a blog post I authored two years ago, during which time Botkube has incorporated additional features and undergone changes to its installation process. Also, this post show how to do it with AWS EKS, but is similar for any K8S flavor.
BotKube is a messaging bot for monitoring and debugging K8S clusters in real-time. Some features are:
- Allow us to execute Kubectl commands on our chat clients.
- By Default uses a ReadOnly Service Account, thus is only possible to execute read commands.
- Can monitor any K8S resource, including Custom Resources (like certificate expiry or backup failure).
- Pretty easy to configure, less than 5 minutes.
- Let us do a quick debug using only our chat client mobile app.
- Deploy on any K8S Flavors (not only EKS)
Table of contents
Prerequisites
- Botkube CLI installed according to the Getting Started guide
- Access to Kubernetes cluster
- Slack Workspace admin access
- Helm
The first step is to install botkube homebrew:
brew install kubeshop/botkube/botkube
Or without homebrew
curl -Lo botkube https://github.com/kubeshop/botkube/releases/download/v1.8.0/botkube-darwin-arm64
chmod +x botkube && mv botkube /usr/local/bin/botkube
Create Slack App
- Go to Slack App console to create an application.
- Click Create New App and select From an app manifest in the popup to create application from manifest.
Now we need to choose the “From an app manifest” option
Select a workspace where you want to create application and click Next.
Select YAML tab, copy & paste one of the following manifests, and click Next, and then Create.
display_information:
name: Botkube
description: Botkube
background_color: "#a653a6"
features:
bot_user:
display_name: Botkube
always_online: false
oauth_config:
scopes:
bot:
- groups:read
- app_mentions:read
- reactions:write
- chat:write
- files:write
- users:read # Remote configuration only: Used to get Real Name for audit reporting
settings:
event_subscriptions:
bot_events:
- app_mention
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
Review the values, and select “Create”
Now we should install to workspace.
In this case we should allow the permissions from Botkube to work with the Slack Worspace
Now we need to get the bot token, for this we should select OAuth & Permissions section on the left sidebar. On this page you can copy the bot token which starts with xoxb…
Now we should go to “Basic information”
Go to the botton to the “App-level tokens” and select “Generate token and scopes”
The token name we should put “botkube” and the scope “connections:write” and select “Generate”
Now we should copy the Botkube App Token
With these values, we need to go to the console, and configure some variables:
where:
- SLACK_CHANNEL_NAME is the channel name where @Botkube is added
- SLACK_API_BOT_TOKEN is the Token you received after installing Botkube app to your Slack workspace
- SLACK_API_APP_TOKEN is the Token you received after installing Botkube app to your Slack workspace and generate in App-Level Token section
- CLUSTER_NAME is the cluster name set in the incoming messages
- ALLOW_KUBECTL set true to allow kubectl command execution by Botkube on the cluster,
- ALLOW_HELM set true to allow helm command execution by Botkube on the cluster,
After installing Botkube app to your Slack workspace, you could see a new bot user with the name “Botkube” added in your workspace. Add that bot to a Slack channel you want to receive notification in. You can add it by inviting @Botkube in a channel.
In this part, we need to execute the command which will install botkube with our parameters
botkube install --version v1.8.0 \
--set communications.default-group.socketSlack.enabled=true \
--set communications.default-group.socketSlack.channels.default.name=${SLACK_CHANNEL_NAME} \
--set communications.default-group.socketSlack.appToken=${SLACK_API_APP_TOKEN} \
--set communications.default-group.socketSlack.botToken=${SLACK_API_BOT_TOKEN} \
--set settings.clusterName=${CLUSTER_NAME} \
--set 'executors.k8s-default-tools.botkube/kubectl.enabled'=${ALLOW_KUBECTL} \
--set 'executors.k8s-default-tools.botkube/helm.enabled'=${ALLOW_HELM}
If everything is okey we should see this
Now we can try the “ping” command, or also execute kubectl commands
Another example with kubectl get ns
We can’t use grep with these commands, however we can use the --filter
option
Lastly, we can also use botkube to execute helm commands, (and also it’s possible to execute flux commands)
Conclusion
This blog post provides an updated look at Botkube, a tool for monitoring and debugging Kubernetes (K8S) clusters in real-time via messaging bots. With new features and an easier installation process, Botkube now supports a wider range of K8S clusters, including AWS EKS, and offers an enhanced user experience. It allows executing Kubectl commands through chat clients, supports monitoring all K8S resources, including custom ones, and ensures security with a ReadOnly Service Account. The setup is straightforward, taking less than five minutes, and facilitates quick debugging directly from a mobile chat app. Detailed steps guide users through installing Botkube, setting up a Slack app, and configuring it to perform Kubernetes management tasks efficiently. Botkube’s versatility and user-friendly design make it a powerful tool for developers and system administrators looking to simplify their Kubernetes cluster management.