Skip to content

Commit

Permalink
[stable/hubot] New Hubot chart (helm#5702)
Browse files Browse the repository at this point in the history
* Create initial hubot chart

* Add hubot icon

* Add help for configuring hubot

* Update maintainer email

* Remove unnecessary namespace parameter

* Fix indentation typo

* Use stable docker image version

* Use IfNotPresent image pull policy

* Move scripts to separated configmap

* Remove namespace completely
  • Loading branch information
darioblanco authored and k8s-ci-robot committed Jun 8, 2018
1 parent b415492 commit 8b4ae5d
Show file tree
Hide file tree
Showing 11 changed files with 407 additions and 0 deletions.
16 changes: 16 additions & 0 deletions stable/hubot/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
description: Hubot chatbot for Slack
name: hubot
version: 0.0.1
appVersion: 0.1.9
home: https://github.com/mind-doc/hubot
sources:
- https://github.com/mind-doc/hubot
keywords:
- slack
- hubot
- chatbot
icon: https://i.imgur.com/UIkAW9t.png
maintainers:
- name: darioblanco
email: [email protected]
126 changes: 126 additions & 0 deletions stable/hubot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Hubot

Hubot 3 chatbot with the Slack adaptor

Learn more: https://github.com/mind-doc/hubot

## TL;DR;

```bash
$ helm install stable/hubot
```

## Introduction

This chart creates a Hubot deployment on a [Kubernetes](http://kubernetes.io)
cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.8+ with Beta APIs enabled

## Installing the Chart

To install the chart with the release name `my-release`:

```bash
$ helm install --name my-release stable/hubot
```

The command deploys Hubot on the Kubernetes cluster using the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```bash
$ helm delete --purge my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the Hubot chart and their default values.

Parameter | Description | Default
--- | --- | ---
`namespace` | namespace to use | `default`
`replicaCount` | desired number of pods | `1`
`image.repository` | container image repository | `minddocdev/hubot`
`image.tag` | container image tag | `latest`
`image.pullPolicy` | container image pull policy | `Always`
`service.type` | type of service to create | `NodePort`
`service.httpPort` | port for the http service | `80`
`ingress.enabled` | flag to add ingress functionality | `false`
`ingress.annotations` | ingress load balancer annotations | `Always`
`ingress.path` | proxied path | `/`
`ingress.hosts` | proxied hosts | `[ hubot.local ]`
`ingress.tls` | tls certificate secrets | `[]`
`resources` | resource requests & limits | `{}`
`nodeSelector` | node selector logic | `{}`
`tolerations` | resource tolerations | `{}`
`affinity` | node affinity | `{}`
`hubot.config` | hubot configuration (environment variables) | `{}`
`hubot.scriptsFolder` | hubot scripts folder path | `/minddocbot/scripts`
`hubot.scripts` | custom hubot scripts | `{ health.coffee: <script content> }`
`hubot.slackToken` | slack hubot integration token | `''`


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```bash
$ helm install --name my-release \
--set key_1=value_1,key_2=value_2 \
stable/hubot
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

```bash
# example for staging
$ helm install --name my-release -f values.yaml stable/hubot
```

> **Tip**: You can use the default [values.yaml](values.yaml)
### Specific hubot settings

#### Config

With the `hubot.config` parameter you can provide a hash that will be used as environment variables by hubot. These environment variables will be picked by hubot's scripts.

For instance:

```
hubot:
config:
HUBOT_STANDUP_PREPEND: '@channel'
```

#### Scripts

In addition, you can add your own scripts, which will be created in the scripts folder, with `.js` or `.coffee` format. See [Hubot Scripting](https://hubot.github.com/docs/scripting/).

By default, this chart adds a health endpoint so Kubernetes can probe the pod.

```
hubot:
scripts:
health.coffee: |
# Description
# A hubot script that exposes a health endpoint
module.exports = (robot) ->
robot.router.get '/health', (req, res) -> res.status(200).end()
```

You can follow the same format for creating your own hubot scripts
```
hubot:
scripts:
hithere.coffee: |
# Description
# A hubot script that is an example for this chart
module.exports = (robot) ->
robot.respond /hi my bot/i, (msg) ->
msg.send 'Hi there my human'
```
19 changes: 19 additions & 0 deletions stable/hubot/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "hubot.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "hubot.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "hubot.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "hubot.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
32 changes: 32 additions & 0 deletions stable/hubot/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "hubot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
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 "hubot.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "hubot.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
11 changes: 11 additions & 0 deletions stable/hubot/templates/configmap-scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "hubot.fullname" . }}-scripts
labels:
app: {{ template "hubot.name" . }}
chart: {{ template "hubot.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{ toYaml .Values.hubot.scripts | indent 2 }}
11 changes: 11 additions & 0 deletions stable/hubot/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "hubot.fullname" . }}
labels:
app: {{ template "hubot.name" . }}
chart: {{ template "hubot.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{ toYaml .Values.hubot.config | indent 2 }}
63 changes: 63 additions & 0 deletions stable/hubot/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: {{ template "hubot.fullname" . }}
labels:
app: {{ template "hubot.name" . }}
chart: {{ template "hubot.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "hubot.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "hubot.name" . }}
release: {{ .Release.Name }}
spec:
volumes:
- name: {{ template "hubot.fullname" . }}-scripts
configMap:
name: {{ template "hubot.fullname" . }}-scripts
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
volumeMounts:
- name: {{ template "hubot.fullname" . }}-scripts
mountPath: {{ .Values.hubot.scriptsFolder }}
envFrom:
- secretRef:
name: {{ template "hubot.fullname" . }}
- configMapRef:
name: {{ template "hubot.fullname" . }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
39 changes: 39 additions & 0 deletions stable/hubot/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "hubot.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "hubot.name" . }}
chart: {{ template "hubot.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions stable/hubot/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "hubot.fullname" . }}
labels:
app: {{ template "hubot.name" . }}
chart: {{ template "hubot.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
HUBOT_SLACK_TOKEN: {{ .Values.hubot.slackToken | b64enc }}
19 changes: 19 additions & 0 deletions stable/hubot/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "hubot.fullname" . }}
labels:
app: {{ template "hubot.name" . }}
chart: {{ template "hubot.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
selector:
app: {{ template "hubot.name" . }}
release: {{ .Release.Name }}
Loading

0 comments on commit 8b4ae5d

Please sign in to comment.