Skip to main content
Version: Unreleased 🚧

Mattermost

Install BotKube to the Mattermost team

Follow the steps below to install BotKube in your Mattermost Team (v5.14.0).

1. Enable Personal Access Token

Login with System Admin account, and in the Menu proceed to System console > Integrations > Integration Management and enable Personal Access Token.

mm_token_access

2. Create BotKube user

To create a BotKube user, if not already created, proceed to the menu and Get a team invite link. Logout from the admin account and paste the link in the address bar and create a user with the username BotKube.

note

You can also use a custom username for your bot. However, it needs to be passed during BotKube installation in one of the further steps.

Export the bot name as an environment variable:

export MATTERMOST_BOT_NAME="{bot_name}"

mm_botkube_user

3. Manage Roles for BotKube user

Login as System Admin, in the Menu, proceed to System console > Users. For BotKube user, Manage Roles and allow tokens and post_all access.

mm_botkube_roles

4. Create a Token for BotKube user

Login as BotKube user, in the Menu, proceed to Account Settings > Security > Personal Access Token > Create and copy the token.

mm_botkube_token

Export it as an environment variable:

export MATTERMOST_TOKEN="{token}"

5. Add BotKube to a channel

Add BotKube user created to the channel you want to receive notifications in.

Export the channel name as an environment variable:

export MATTERMOST_CHANNEL="{channel_name}"

Install BotKube 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:

    helm repo add botkube https://charts.botkube.io
    helm repo update
  • Deploy BotKube backend using helm install in your cluster:

    export MATTERMOST_SERVER_URL={mattermost_server_url}
    export MATTERMOST_CERT={mattermost_cert_path}
    export MATTERMOST_TEAM={mattermost_team_name}
    export CLUSTER_NAME={cluster_name}
    export ALLOW_KUBECTL={allow_kubectl}

    helm install --version v0.13.0 botkube --namespace botkube --create-namespace \
    --set communications.default-group.mattermost.enabled=true \
    --set communications.default-group.mattermost.url=${MATTERMOST_SERVER_URL} \
    --set communications.default-group.mattermost.cert=${MATTERMOST_CERT} \
    --set communications.default-group.mattermost.token=${MATTERMOST_TOKEN} \
    --set communications.default-group.mattermost.team=${MATTERMOST_TEAM} \
    --set communications.default-group.mattermost.channels.default.name=${MATTERMOST_CHANNEL} \
    --set communications.default-group.mattermost.botName=${MATTERMOST_BOT_NAME} \
    --set settings.clusterName=${CLUSTER_NAME} \
    --set executors.kubectl-read-only.kubectl.enabled=${ALLOW_KUBECTL} \
    botkube/botkube

    where,

    • MATTERMOST_SERVER_URL is the URL (including http/https schema) where Mattermost is running

    • MATTERMOST_CERT (optional) is the SSL certificate file for HTTPS connection. Place it in Helm directory and specify the path

    • MATTERMOST_TOKEN is the Token received by creating Personal Access Token for BotKube user

    • MATTERMOST_TEAM is the Team name where BotKube is added

    • MATTERMOST_CHANNEL is the Channel name where BotKube is added and used for communication

    • MATTERMOST_BOT_NAME is the Mattermost bot username (usually it is BotKube)

    • 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

    • To deploy with TLS, replace MATTERMOST_CERT with the location of the SSL certificate file placed in Helm directory. Leave this value to None if deploying without TLS.

      Configuration syntax is explained here. Full Helm chart parameters list is documented here.

    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:

    1. Create a new config.yaml file and add Kubernetes resource configuration as described on the source page.

    2. Pass the YAML file as a flag to helm install command, e.g.:

      helm install --version v0.13.0 --name botkube --namespace botkube --create-namespace -f /path/to/config.yaml --set=...other args..

    Alternatively, you can also update the configuration at runtime as documented here

Remove BotKube from Mattermost Team

  • Deactivate or remove BotKube user from Mattermost Team. Login as System Admin, in the Menu proceed to System console -> Users -> botkube -> Deactivate
  • Archive Channel created for BotKube communication if required.

Remove BotKube from Kubernetes cluster

Execute following command to completely remove BotKube and related resources from your cluster

helm uninstall botkube