Slack Event Monitoring
In this topic, you discover the step-by-step process of creating a vibrant Slack app and seamlessly integrating both kube-state-metrics (KSM) events and KubeSlice events into a dynamic Slack channel. Unleash the power of real-time updates and vibrant notifications, making your Slack workspace a hub of insightful information. Let's dive in and explore this exciting integration journey!
Create an App
Create an app using the Slack API in your workspace.
To create an app:
Open the Slack API console.
Click the Create an App button.
- Select From an app manifest to configure your app scopes and settings.
- Select a workspace where you want to create an app and click Next.
In the Enter app manifest below section, click on the YAML tab and enter the following manifest:
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
- 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: falseClick Next.
In the Review summary & create your app section, review the details and click Create.
Install an App
Once you have successfully created your app, you will be directed to an application details page that provides you with the option to install the app in your desired workspace.
To install an app to your workspace:
Go to Settings > Basic Information on the left sidebar.
In the Building Apps for Slack section, under Install your app, click the Install to workspace button.
Click Allow to finish the installation.
Get an OAuth Token
During the configuration process of botkube in Slack, it is essential to provide the OAuth token for authentication purposes. This token serves as a secure credential that verifies the identity of the botkube integration and enables seamless communication between Slack and botkube.
To get an oauth token for your workspace:
Go to Features > OAuth & Permissions on the left sidebar.
Copy the Bot User OAuth Token and save the token for later use while deploying the kubeslice-botkube bundle on the controller and worker clusters.
Get an App-Level Token
To establish a web socket connection with Slack App using Socket Mode, you need an App-Level token. This token is specifically required to facilitate the communication and interaction between your Slack App and the web socket, ensuring a smooth and uninterrupted connection.
To get an app-level token:
Go to Settings > Basic Information on the left sidebar.
Click the Generate Token and Scopes button.
- In the Generate an app-level token section, enter a token name. For example,
botkube
is a token name.
Click Add Scope and select connections:write scope.
Click Generate.
Review the details and click Done. Copy the app-level token for later use while deploying the kubeslice-botkube bundle on the controller and worker clusters.
Create Slack Channel for Events
Once you have successfully installed the Botkube application, you will notice a new bot user named botkube
added to your workspace.
Next, proceed to create two channels within your workspace to receive KSM and KubeSlice events. Save the channel names for later use.
To receive notifications in a specific Slack channel, you need to add the Botkube bot. This can be done by inviting the @Botkube user to the desired channel.
Deploy the kubeslice-botkube Bundle
To deploy the kubeslice-botkube bundle:
Switch the context to controller cluster.
kubectx <cluster_name>
Add the kubeslice-botkube repo using the following command:
helm repo add kubeslice/botkube
Use the following command to create the
botkube
namespace on the controller and worker clusters.kubectl create ns botkube
Use the following command to deploy the kubeslice-botkube bundle on the controller cluster:
note
Replace the
ksm_channel_name
,kubeslice_event_channel_name
,cluster_name
,app_token
, andbot_token
in the command below with your values.helm install kubeslice-botkube kubeslice/botkube --set "sources.k8s-controller-events.botkube/kubernetes.enabled=true" --namespace botkube \
--set communications.default-group.socketSlack.enabled=true \
--set communications.default-group.socketSlack.channels.default.name=<ksm_channel_name> \
--set communications.default-group.socketSlack.channels.kubeslice.name=<kubeslice_event_channel_name> \
--set communications.default-group.socketSlack.appToken=<app_token> \
--set communications.default-group.socketSlack.botToken=<bot_token> \
--set settings.clusterName=<cluster_name> \
--set 'executors.k8s-default-tools.botkube/kubectl.enabled'=true \
--set 'executors.k8s-default-tools.botkube/helm.enabled'=trueSwitch the context to worker cluster(s).
kubectx <cluster_name>
Use the following command to deploy the kubeslice-botkube bundle on each of the worker cluster(s):
note
Replace the
ksm_channel_name
,kubeslice_event_channel_name
,cluster_name
,app_token
, andbot_token
in the command below with your values.helm install kubeslice-botkube kubeslice/botkube --set "sources.k8s-worker-events.botkube/kubernetes.enabled=true" --namespace botkube \
--set communications.default-group.socketSlack.enabled=true \
--set communications.default-group.socketSlack.channels.default.name=<ksm_channel_name> \
--set communications.default-group.socketSlack.channels.kubeslice.name=<kubeslice_event_channel_name> \
--set communications.default-group.socketSlack.appToken=<app_token> \
--set communications.default-group.socketSlack.botToken=<bot_token> \
--set settings.clusterName=<cluster_name> \
--set 'executors.k8s-default-tools.botkube/kubectl.enabled'=true \
--set 'executors.k8s-default-tools.botkube/helm.enabled'=true
Slack KSM Events
After deploying the charts in the workspace, you will start receiving notifications. The KSM events received in the Slack channel are depicted in the figures below:
Slack KubeSlice Events
Controller Events
The Slack channel displays the KubeSlice events for the controller cluster, as depicted in the following figure.
Worker Events
The Slack channel displays the KubeSlice events for the worker cluster, as depicted in the following figure.