We’d love your help!
BotKube is MIT Licensed and accepts contributions via GitHub pull requests. This document outlines some of the conventions on development workflow, commit message formatting, contact points and other resources to make it easier to get your contributions accepted.
We gratefully welcome improvements to documentation as well as to code.
You can contribute to documentation by following these instructions
Before you proceed, make sure you have installed BotKube Slack/Mattermost/Teams app and copied the required token as per the steps documented here
go 1.18
installed.make
and docker
installed on your machine.git clone https://github.com/kubeshop/botkube.git
Now you can build and run BotKube by one of the following ways
Build BotKube and create a new container image tagged as ghcr.io/kubeshop/botkube:v9.99.9-dev
. Choose one option:
Single target build for your local K8s cluster
This is ideal for running BotKube on a local cluster, e.g. using kind or minikube
.
Remember to set the IMAGE_PLATFORM
env var to your target architecture. For example, the command below builds the linux/arm64
target. By default, the build targets linux/amd64
.
IMAGE_PLATFORM=linux/arm64 make container-image-single
docker tag ghcr.io/kubeshop/botkube:v9.99.9-dev <your_account>/botkube:v9.99.9-dev
docker push <your_account>/botkube:v9.99.9-dev
Where <your_account>
is Docker hub account to which you can push the image.
Multi-arch target builds for any K8s cluster
This is ideal for running BotKube on remote clusters.
When tagging your dev image take care to add your target image architecture as a suffix. For example, in the command below we added -amd64
as our target architecture.
This ensures the image will run correctly on the target K8s cluster.
Note This command takes some time to run as it builds the images for multiple architectures.
make container-image
docker tag ghcr.io/kubeshop/botkube:v9.99.9-dev-amd64 <your_account>/botkube:v9.99.9-dev
docker push <your_account>/botkube:v9.99.9-dev
Where <your_account>
is Docker hub account to which you can push the image.
Deploy the newly created image in your cluster:
helm install botkube --namespace botkube --create-namespace \
--set communications.slack.enabled=true \
--set communications.slack.channel=<SLACK_CHANNEL_NAME> \
--set communications.slack.token=<SLACK_API_TOKEN_FOR_THE_BOT> \
--set settings.clustername=<CLUSTER_NAME> \
--set settings.kubectl.enabled=<ALLOW_KUBECTL> \
--set image.registry=<image_registry e.g. docker.io> \
--set image.repository=<your_account>/botkube \
--set image.tag=v9.99.9-dev \
./helm/botkube
Check values.yaml for default options.
For faster development, you can also build and run BotKube outside K8s cluster.
Build BotKube binary if you don’t want to build the container image, you can build the binary like this,
# Fetch the dependencies
go mod download
# Build the binary
go build ./cmd/botkube/
Use templates to create configuration files:
cp resource_config.yaml.tpl resource_config.yaml
cp comm_config.yaml.tpl comm_config.yaml
Edit the newly created resource_config.yaml
and comm_config.yaml
files to configure resource and set communication credentials.
Export paths for configuration files:
export BOTKUBE_CONFIG_PATHS="$(pwd)/resource_config.yaml,$(pwd)/comm_config.yaml"
Export the path to Kubeconfig:
export KUBECONFIG=/Users/$USER/.kube/config # set custom path if necessary
Make sure that correct context is set and you are able to access your Kubernetes cluster
$ kubectl config current-context
minikube
$ kubectl cluster-info
Kubernetes master is running at https://192.168.39.233:8443
CoreDNS is running at https://192.168.39.233:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
...
Run BotKube binary
./botkube
Before making any significant changes, please open an issue. Discussing your proposed changes ahead of time will make the contribution process smooth for everyone.
Once we’ve discussed your changes and you’ve got your code ready, make sure that the build steps mentioned above pass. Open your pull request against main
branch.
To avoid build failures in CI, install golangci-lint
v1.46 and run:
# From project root directory
make lint
This will run the golangci-lint
tool to lint the Go code.
Make sure your pull request has good commit messages:
Try to squash unimportant commits and rebase your changes on to the main
branch, this will make sure we have clean log of changes.