Skip to content

Commit

Permalink
Merge pull request #6 from infracloudio/develop
Browse files Browse the repository at this point in the history
merge develop to master
  • Loading branch information
PrasadG193 authored Jan 4, 2019
2 parents 383711f + b9ddcad commit 0839f2f
Show file tree
Hide file tree
Showing 28 changed files with 251 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ before_script:
- dep ensure

script:
- build/docker.sh infracloudio/kubeops latest
- build/docker.sh infracloudio/botkube latest
67 changes: 15 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
# kubeops
[![Build Status](https://travis-ci.org/infracloudio/kubeops.svg?branch=master)](https://travis-ci.org/infracloudio/kubeops)
# botkube
[![Build Status](https://travis-ci.org/infracloudio/botkube.svg?branch=master)](https://travis-ci.org/infracloudio/botkube)

A slack bot which watches your kubernetes clusters and notifies about resources life cycles, errors, events and provide recommendations about the best practices while creating resources.
You can also ask kubeops to execute kubectl commands on k8s cluster which helps debugging a application or cluster.
You can also ask botkube to execute kubectl commands on k8s cluster which helps debugging a application or cluster.

## Building
```
build/docker.sh <docker-repo> <tag>
```

## Creating slack bot
- Create a bot with name `kubeops` https://my.slack.com/services/new/bot
- Set icon, name and copy API token (required to configure kubeops)
- Add the bot into a channel by inviting with `@kubeops` in the message area
- Create a bot with name `botkube` https://my.slack.com/services/new/bot
- Set icon, name and copy API token (required to configure botkube)
- Add the bot into a channel by inviting with `@botkube` in the message area

## Configuration
Kubeops reads configurations from `kubeopsconfig.yaml` file placed at `KUBEOPS_CONFIG_PATH`
Syntax:
```
# Resources you want to watch
resources:
- name: RESOURCE_NAME # Name of the resources e.g pods, deployments, ingresses, etc. (Resource name must be in plural form)
namespaces: # List of namespaces, "all" will watch all the namespaces
- all
events: # List lifecycle events you want to receive, e.g create, update, delete OR all
- all
- name: pods
namespaces:
- kube-system
- default
events:
- create
- delete
- name: roles
namespaces:
- all
events:
- create
- delete
# K8S errors/warnings events you want to receive for the configured resources
events:
types:
- normal
- warning
Kubeops reads configurations from `config.yaml` file placed at `CONFIG_PATH`
e.g https://github.com/infracloudio/botkube/config.yaml

# Check true if you want to receive recommendations
# about the best practices for the created resource
recommendations: true
# Channels configuration
communications:
slack:
channel: 'SLACK_CHANNEL_NAME'
token: 'SLACK_API_TOKEN_FOR_THE_BOT'
```
Supported resources:
Supported resources for configuration:
- pods
- nodes
- services
Expand All @@ -78,13 +41,13 @@ Supported resources:
## Installing on kubernetes cluster
### Using helm
- Follow https://docs.helm.sh/using_helm/#installing-helm guide to install helm.
- Clone the kubeops github repository.
- Clone the botkube github repository.
```
git clone https://github.com/infracloudio/kubeops.git
git clone https://github.com/infracloudio/botkube.git
```
- Update default `kubeopsconfig` in `helm/kubeops/values.yaml` to watch the resources you want.
- Deploy kubeops using `helm install` in your cluster.
- Update default `botkubeconfig` in `helm/botkube/values.yaml` to watch the resources you want.
- Deploy botkube using `helm install` in your cluster.
```
helm install --name kubeops --namespace kubeops --set kubeopsconfig.communications.slack.channel={SLACK_CHANNEL_NAME} --set kubeopsconfig.communications.slack.token={SLACK_API_TOKEN_FOR_THE_BOT} helm/kubeops/
helm install --name botkube --namespace botkube --set botkubeconfig.communications.slack.channel={SLACK_CHANNEL_NAME} --set botkubeconfig.communications.slack.token={SLACK_API_TOKEN_FOR_THE_BOT} helm/botkube/
```
- Send `@kubeops help` in the channel to see if `kubeops` is responding.
- Send `@botkube help` in the channel to see if `botkube` is responding.
18 changes: 9 additions & 9 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ FROM golang:1.11-alpine
RUN mkdir -p /go/src/app
WORKDIR /go/src/app

CMD ["/controller"]
CMD ["/botkube"]

RUN mkdir -p /go/src/github.com/infracloudio/kubeops/vendor && \
mkdir -p /go/src/github.com/infracloudio/kubeops/cmd && \
mkdir -p /go/src/github.com/infracloudio/kubeops/pkg
RUN mkdir -p /go/src/github.com/infracloudio/botkube/vendor && \
mkdir -p /go/src/github.com/infracloudio/botkube/cmd && \
mkdir -p /go/src/github.com/infracloudio/botkube/pkg

COPY vendor/ /go/src/github.com/infracloudio/kubeops/vendor
COPY cmd/ /go/src/github.com/infracloudio/kubeops/cmd
COPY pkg/ /go/src/github.com/infracloudio/kubeops/pkg
COPY vendor/ /go/src/github.com/infracloudio/botkube/vendor
COPY cmd/ /go/src/github.com/infracloudio/botkube/cmd
COPY pkg/ /go/src/github.com/infracloudio/botkube/pkg

RUN cd /go/src/github.com/infracloudio/kubeops/cmd/controller && \
RUN cd /go/src/github.com/infracloudio/botkube/cmd/botkube && \
go build && \
cp /go/src/github.com/infracloudio/kubeops/cmd/controller/controller /controller
cp /go/src/github.com/infracloudio/botkube/cmd/botkube/botkube /botkube

# Install kubectl
ENV KUBE_LATEST_VERSION="v1.13.0"
Expand Down
2 changes: 1 addition & 1 deletion build/docker.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set +x

BUILD_ROOT=$(dirname $0)
IMAGE_REPO=${1:-infracloud/kubeops}
IMAGE_REPO=${1:-infracloud/botkube}
IMAGE_TAG=${2:-latest}

pushd ${BUILD_ROOT}/..
Expand Down
8 changes: 4 additions & 4 deletions cmd/controller/main.go → cmd/botkube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package main
import (
"fmt"

"github.com/infracloudio/kubeops/pkg/config"
"github.com/infracloudio/kubeops/pkg/controller"
log "github.com/infracloudio/kubeops/pkg/logging"
"github.com/infracloudio/kubeops/pkg/slack"
"github.com/infracloudio/botkube/pkg/config"
"github.com/infracloudio/botkube/pkg/controller"
log "github.com/infracloudio/botkube/pkg/logging"
"github.com/infracloudio/botkube/pkg/slack"
)

func main() {
Expand Down
27 changes: 22 additions & 5 deletions kubeopsconfig.yaml → config.yaml
Original file line number Diff line number Diff line change
@@ -1,84 +1,100 @@
## Resources you want to watch
resources:
- name: pods
namespaces:
- name: pods # Name of the resources e.g pods, deployments, ingresses, etc. (Resource name must be in plural form)
namespaces: # List of namespaces, "all" will watch all the namespaces
- all
events:
events: # List of lifecycle events you want to receive, e.g create, update, delete OR all
- create
- delete
- name: services
namespaces:
- all
events:
- create
- delete
- name: deployments
namespaces:
- all
events:
- create
- delete
- name: ingresses
namespaces:
- all
events:
- create
- delete
- name: nodes
namespaces:
- all
events:
- create
- delete
- name: namespaces
namespaces:
- all
events:
- create
- delete
- name: persistentvolumes
namespaces:
- all
events:
- create
- delete
- name: persistentvolumeclaim
namespaces:
- all
events:
- create
- delete
- name: secrets
namespaces:
- all
events:
- create
- delete
- name: configmaps
namespaces:
- all
events:
- create
- delete
- name: daemonsets
namespaces:
- all
events:
- create
- delete
- name: jobs
namespaces:
- all
events:
- create
- delete
- name: roles
namespaces:
- all
events:
- create
- delete
- name: rolebindings
namespaces:
- all
events:
- create
- delete
- name: clusterroles
namespaces:
- all
events:
- create
- delete
- name: clusterrolebindings
namespace:
- all
events:
- create
- delete
- name: nodes
namespaces:
Expand All @@ -87,13 +103,14 @@ resources:
- create
- delete

# Events you want to watch
# K8S error/warning events you want to receive for the configured resources
events:
types:
#- normal
- warning

# Recommendations you want to receive
# Check true if you want to receive recommendations
# about the best practices for the created resource
recommendations: true

# Channels configuration
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion helm/kubeops/Chart.yaml → helm/botkube/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: kubeops
name: botkube
version: 0.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kubeops.name" -}}
{{- define "botkube.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Expand All @@ -11,7 +11,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "kubeops.fullname" -}}
{{- define "botkube.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
Expand All @@ -27,6 +27,6 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kubeops.chart" -}}
{{- define "botkube.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "kubeops.fullname" . }}-clusterrole
name: {{ include "botkube.fullname" . }}-clusterrole
labels:
app.kubernetes.io/name: {{ include "kubeops.name" . }}
helm.sh/chart: {{ include "kubeops.chart" . }}
app.kubernetes.io/name: {{ include "botkube.name" . }}
helm.sh/chart: {{ include "botkube.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
rules:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "kubeops.fullname" . }}-clusterrolebinding
name: {{ include "botkube.fullname" . }}-clusterrolebinding
labels:
app.kubernetes.io/name: {{ include "kubeops.name" . }}
helm.sh/chart: {{ include "kubeops.chart" . }}
app.kubernetes.io/name: {{ include "botkube.name" . }}
helm.sh/chart: {{ include "botkube.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "kubeops.fullname" . }}-clusterrole
name: {{ include "botkube.fullname" . }}-clusterrole
subjects:
- kind: ServiceAccount
name: {{ include "kubeops.fullname" . }}-sa
name: {{ include "botkube.fullname" . }}-sa
namespace: {{ .Release.Namespace }}
15 changes: 15 additions & 0 deletions helm/botkube/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "botkube.fullname" . }}-configmap
labels:
app.kubernetes.io/name: {{ include "botkube.name" . }}
helm.sh/chart: {{ include "botkube.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
config.yaml: |
{{- with .Values.config }}
{{- toYaml . | nindent 4 }}
{{- end }}

Loading

0 comments on commit 0839f2f

Please sign in to comment.