-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from infracloudio/develop
Includes following changes: - Multicluster support - Add Makefile - Disable help command (since moved to "Slash Command")
- Loading branch information
Showing
13 changed files
with
272 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
release=1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
IMAGE_REPO=infracloud/botkube | ||
TAG=$(shell cut -d'=' -f2- .release) | ||
|
||
.DEFAULT_GOAL := build | ||
.PHONY: release git-tag check-git-status build pre-build tag-image publish | ||
|
||
#Docker Tasks | ||
#Make a release | ||
release: check-git-status build tag-image publish git-tag | ||
@echo "Successfully released version $(TAG)" | ||
|
||
#Create a git tag | ||
git-tag: | ||
@echo "Creating a git tag" | ||
@git add . | ||
@git commit -m "Bumped to version $(TAG)" ; | ||
@git tag $(TAG) ; | ||
@git push --tags origin master; | ||
@echo 'Git tag pushed successfully' ; | ||
|
||
#Check git status | ||
check-git-status: | ||
@echo "Checking git status" | ||
@if [ -n "$(shell git tag | grep $(TAG))" ] ; then echo 'Tag already exists' && exit 1 ; fi | ||
@if [ -z "$(shell git remote -v)" ] ; then echo 'No remote to push tags to' && exit 1 ; fi | ||
@if [ -z "$(shell git config user.email)" ] ; then echo 'Unable to detect git credentials' && exit 1 ; fi | ||
|
||
#Build the image | ||
build: pre-build | ||
@echo "Building docker image" | ||
@docker build --build-arg GOOS_VAL=$(shell go env GOOS) --build-arg GOARCH_VAL=$(shell go env GOARCH) -t $(IMAGE_REPO) -f build/Dockerfile --no-cache . | ||
@echo "Docker image build successfully" | ||
|
||
#Pre-build checks | ||
pre-build: | ||
@echo "Checking system information" | ||
@if [ -z "$(shell go env GOOS)" ] || [ -z "$(shell go env GOARCH)" ] ; then echo 'Could not determine the system architecture.' && exit 1 ; fi | ||
|
||
|
||
#Tag images | ||
tag-image: | ||
@echo 'Tagging image' | ||
@docker tag $(IMAGE_REPO) $(IMAGE_REPO):$(TAG) | ||
@docker tag $(IMAGE_REPO) $(IMAGE_REPO):latest | ||
|
||
#Docker push image | ||
publish: | ||
@echo "Pushing docker image to repository" | ||
@docker login | ||
@docker push $(IMAGE_REPO):$(TAG) | ||
@docker push $(IMAGE_REPO):latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Multi-cluster Support | ||
|
||
#### Assumptions | ||
`@botkube` commands refer to all the commands in the slack bot which currently supports: | ||
- kubectl | ||
- notifier | ||
- ping | ||
|
||
|
||
### Summary | ||
Add Multi-cluster support for Botkube, where a single bot can monitor multiple clusters and respond to `@botkube` commands with cluster specific results. | ||
|
||
### Motivation | ||
Currently in multi-cluster scenario, a Slack bot authenticates all the clusters with a same authentication token. Thus running `@botkube` command returns response from all the configured clusters, irrespective of the slack channel or group. For `@botkube` command execution, we need a particular cluster specific output. | ||
|
||
### Design | ||
|
||
This design approach adds a flag `--cluster-name` to all `@botkube` commands. Use of that flag is optional in a cluster specific channel. | ||
|
||
Botkube `Notifier` commands are restricted to a dedicated channel for a cluster only and `--cluster-name` flag is ignored. | ||
|
||
Botkube `ping` command with the `--cluster-name` flag returns `pong` response from the cluster specified in the flag, else you get response from all the clusters. `Ping` command without --cluster-name flag can be used to list all the configured clusters in the slack bot and identify you cluster's name among them. | ||
|
||
For `kubectl` commands in a dedicated channel to a cluster, if `--cluster-name` flag is used, it responds with the output for the cluster specified in flag, else it checks if the channel in the request matches the `config.Communications.Slack.Channel` and responds if true else ignores. | ||
|
||
For `kubectl` commands in a group, Direct message or channel not dedicated to any cluster, the `--cluster-name` flag is mandatory. The executor checks if the `--cluster-name` flag is present in the request. If yes, it gets the cluster's name from the flag and compares with `c.Settings.ClusterName` from the config file, if it matches then it responds with the required output to the slack bot and if it doesn't match, it ignores the request. And if the `--cluster-name` flag is absent for kubectl commands, it responds to the slack bot saying 'Please specify the cluster-name'. | ||
|
||
For example - | ||
```sh | ||
@Botkube get pods --cluster-name={CLUSTER_NAME} | ||
``` | ||
where, | ||
`CLUSTER_NAME` is the name of the cluster you want to query. | ||
|
||
To get the list of all clusters configured in the slack, you can run the following command in slack. | ||
|
||
```sh | ||
@Botkube ping | ||
``` | ||
|
||
##### Workflow | ||
|
||
 | ||
|
||
|
||
### Drawbacks | ||
The `--cluster-name` flag is mandated for kubectl and notifier commands resulting additional overhead. | ||
|
||
### Alternatives | ||
We can add channel specific authentication token or completely dedicate a channel to a particular cluster which requires changes in the slack code. | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.