forked from harbur/kubebot
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README and upload deployment manifest
- Loading branch information
Showing
1 changed file
with
77 additions
and
7 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 |
---|---|---|
|
@@ -4,19 +4,83 @@ Kubebot is a Kubernetes chatbot for Slack. | |
|
||
This project is in active development and it's __not ready__ for production yet. | ||
|
||
## Prerequisite | ||
|
||
First, you’ll need a Kubernetes cluster. You can start with creating a Kubernetes cluster with Google Container Engine following the [quickstart](https://cloud.google.com/container-engine/docs/quickstart), or pick other solutions from [here](http://kubernetes.io/docs/getting-started-guides/). | ||
|
||
|
||
## Setup | ||
To run Kubebot on Slack, first you need to [create a new bot](https://my.slack.com/services/new/bot) user integration on Slack and get the `token`. | ||
|
||
To run Kubebot on Slack, first you need to [create a new bot](https://my.slack.com/services/new/bot) user integration on Slack and get the `token` (See [Slack bot users](https://api.slack.com/bot-users) for more details). | ||
|
||
Then you need to know the channel ids where you want to run the Kubebot. You can get them on `https://slack.com/api/channels.list?token={REPLACE WITH YOUR TOKEN}` | ||
|
||
## How to run it | ||
|
||
### Using Kubernetes charts | ||
### Create a Secret | ||
|
||
First, create a Kubernetes [Secret](http://kubernetes.io/docs/user-guide/secrets/) to hold your sensitive information. | ||
|
||
``` | ||
kubectl create secret generic kubebot --from-literal=token=<your_token_here> --from-literal=channel=<your_channel_id_here> | ||
``` | ||
|
||
### Create a kubebot Deployment | ||
|
||
Then, create the following kubebot Deployment that consumes the secret you just created, and that’s it! | ||
|
||
Open the (kubebot-deployment.yaml)[kubebot-deployment.yaml] file and modify the kubebot container environment variables to control things like who the kubebot will listen to, and what valid kubectl commands are allowed. | ||
|
||
```yaml | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: kubebot | ||
labels: | ||
component: kubebot | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
component: kubebot | ||
spec: | ||
containers: | ||
- name: kubebot | ||
image: harbur/kubebot:0.1.0 | ||
imagePullPolicy: Always | ||
env: | ||
# Create a secret with your slack bot token and reference it here | ||
- name: KUBEBOT_SLACK_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: kubebot | ||
key: token | ||
# Create a secret with your slack bot channel id and reference it here | ||
- name: KUBEBOT_SLACK_CHANNELS_IDS | ||
valueFrom: | ||
secretKeyRef: | ||
name: kubebot | ||
key: channel | ||
# Alternatively, use this instead if you don't need to put channel ids in a secret; use a space as a separator | ||
# - name: KUBEBOT_SLACK_CHANNELS_IDS | ||
# value: "1234 4321" | ||
# Specify slack admins that kubebot should listen to; use a space as a separator | ||
- name: KUBEBOT_SLACK_ADMINS_NICKNAMES | ||
value: "user1 user2" | ||
# Specify valid kubectl commands that kubebot should support; use a space as a separator | ||
- name: KUBEBOT_SLACK_VALID_COMMANDS | ||
value: "get describe scale" | ||
``` | ||
The fastest way to run Kubebot in your Kubernetes cluster is using the [Kubebot chart](https://github.com/harbur/kubebot-chart) for Kubernetes. | ||
```console | ||
$ kubectl create -f kubebot-deployment.yaml | ||
deployment "kubebot" created | ||
``` | ||
|
||
|
||
### Running the binary | ||
### Alternative: Running the binary | ||
|
||
It is possible to run the binary locally or in a server. First you need to download and compile this project using the Go compiler: | ||
|
||
|
@@ -27,7 +91,6 @@ git clone [email protected]:harbur/kubebot.git | |
go install -v github.com/harbur/kubebot | ||
``` | ||
|
||
|
||
Then set up the following environment variables: | ||
|
||
``` | ||
|
@@ -44,9 +107,16 @@ KUBEBOT_SLACK_ADMINS_NICKNAMES="nickname1 nickname2" | |
KUBEBOT_SLACK_VALID_COMMANDS="get describe logs explain" | ||
``` | ||
|
||
|
||
After the setup, you can run the binary: | ||
|
||
``` | ||
kubebot | ||
``` | ||
``` | ||
|
||
### Interact with the bot | ||
|
||
Now, start asking the bot to run those [kubectl](http://kubernetes.io/docs/user-guide/kubectl/kubectl/) commands for you. | ||
|
||
![kubebot](kubebot.png "kubebot") | ||
|
||
|