Botkube is one of the best tool opensource I know, this very simple to install and useful. The mechanism is Botkube need token to connect each other with slack. So the first thing we need to install app on slack to configure collaborate with botkube. Actually documentation of botkube is helpull and complete, but you know this is not tutorial page :)). I just want to keep in my notes if in anytime I need.
First | Install app on slack
- 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.
- 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.
Public Channel only
display_information:
name: Botkube
description: Botkube
background_color: "#a653a6"
features:
bot_user:
display_name: Botkube
always_online: false
oauth_config:
scopes:
bot:
- channels:read
- app_mentions:read
- chat:write
- files:write
settings:
event_subscriptions:
bot_events:
- app_mention
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
Private Channel Only
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
- chat:write
- files:write
settings:
event_subscriptions:
bot_events:
- app_mention
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
Second | Install Botkube to the Slack workspace
Once the application is created, you will be redirected to application details page. Press the Install your app button, select the workspace and click Allow to finish installation.
Third | Obtain Bot Token
Follow the steps to obtain the Bot Token:
Select OAuth & Permissions section on the left sidebar. On this page you can copy the bot token which starts with xoxb….
Export Slack Bot Token as follows:
export SLACK_API_BOT_TOKEN="{botToken}"
Fourth | Generate and obtain App-Level Token
Slack App with Socket Mode requires an App-Level Token for the websocket connection. Follow the steps to generate an App-Level Token:
Select Basic Information link from the left sidebar and scroll down to section App-Level Token. Click on the Generate Token and Scopes button.
Enter a Name, select connections:write scope, and click Generate.
Copy App-Level Token and export it as follows:
export SLACK_API_APP_TOKEN="${appToken}"
Five | Add Botkube user to a Slack channel
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.
Kubernetes
Install Botkube Backend in Kubernetes cluster
- We use Helm to install Botkube in Kubernetes. Follow this guide to install helm if you don’t have it installed already.
- Add botkube chart repository:
Execute this command
helm repo add botkube https://charts.botkube.io
helm repo update
- Deploy Botkube backend using helm install in your cluster:
Execute this command
export CLUSTER_NAME={cluster_name}
export ALLOW_KUBECTL={allow_kubectl}
export SLACK_CHANNEL_NAME={channel_name}
helm install --version v0.16.0 botkube --namespace botkube --create-namespace \
--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.kubectl-read-only.kubectl.enabled=${ALLOW_KUBECTL} \
botkube/botkube`3
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
Send @Botkube ping in the channel to see if Botkube is running and responding.
With the default configuration, Botkube will watch all the resources in all the namespaces for create, delete and error events.
If you wish to monitor only specific resources, follow the steps given below:
Create a new config.yaml file and add Kubernetes resource configuration as described on the source page.
Pass the YAML file as a flag to helm install command, e.g.:
helm install --version v0.16.0 --name botkube --namespace botkube --create-namespace -f /path/to/config.yaml --set=...other args..