Skip to content

Commit

Permalink
Merge pull request #55 from rapittdev/chatops-ha
Browse files Browse the repository at this point in the history
Chatops integration
  • Loading branch information
armab authored Apr 16, 2019
2 parents d843026 + 0ce2774 commit 968816b
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
charts
*.lock
.DS_Store
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## In Development

## v0.11.0
* Add st2chatops support (@mosn, @rapittdev) (#55)

## v0.10.0
* Bump versions of all dependencies (#50)
* Allow st2sensorcontainer to be partitioned (#51)
Expand Down
3 changes: 2 additions & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
# Update StackStorm version here to rely on other Docker images tags
appVersion: 3.0dev
name: stackstorm-ha
version: 0.10.0
version: 0.11.0
description: StackStorm K8s Helm Chart, optimized for running StackStorm in HA environment.
home: https://stackstorm.com/#product
icon: https://avatars1.githubusercontent.com/u/4969009
Expand All @@ -12,6 +12,7 @@ keywords:
- st2
- stackstorm
- devops
- chatops
- event-driven
- auto-remediation
- IFTTT
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ Having `1` st2garbagecollector replica for K8s Deployment is enough, considering
By default this process does nothing and needs to be configured in st2.conf settings (via `values.yaml`).
Purging stale data can significantly improve cluster abilities to perform faster and so it's recommended to configure st2garbagecollector in production.

### [st2chatops](https://docs.stackstorm.com/chatops/index.html)
StackStorm ChatOps service, based on hubot engine, custom stackstorm integration module and preinstalled list of chat adapters.
Due to Hubot limitation, st2chatops doesn't provide mechanisms to guarantee high availability and so only single `1` node of st2chatops is deployed.
This service is disabled by default. Please refer to Helm `values.yaml` about how to enable and configure st2chatops with ENV vars for your preferred chat service.

### [MongoDB HA ReplicaSet](https://github.com/helm/charts/tree/master/stable/mongodb-replicaset)
StackStorm works with MongoDB as a database engine. External Helm Chart is used to configure MongoDB HA [ReplicaSet](https://docs.mongodb.com/manual/tutorial/deploy-replica-set/).
By default `3` nodes (1 primary and 2 secondaries) of MongoDB are deployed via K8s StatefulSet.
Expand Down
84 changes: 84 additions & 0 deletions templates/deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1319,3 +1319,87 @@ spec:
- name: st2-virtualenvs-vol
emptyDir: {}
{{- end }}

{{ if .Values.st2chatops.enabled -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-st2chatops{{ template "enterpriseSuffix" . }}
labels:
app: st2chatops
tier: backend
vendor: stackstorm
support: {{ template "supportMethod" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
matchLabels:
app: st2chatops
support: {{ template "supportMethod" . }}
release: {{ .Release.Name }}
# As hubot can't be HA scaled properly, we deploy only single replica of st2chatops
replicas: 1
template:
metadata:
labels:
app: st2chatops
tier: backend
vendor: stackstorm
support: {{ template "supportMethod" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
checksum/chatops: {{ include (print $.Template.BasePath "/secrets_st2chatops.yaml") . | sha256sum }}
spec:
containers:
- name: st2chatops{{ template "enterpriseSuffix" . }}
image: "{{ .Values.st2chatops.image.repository | default "stackstorm" }}/{{ .Values.st2chatops.image.name | default "st2chatops" }}:{{ tpl (.Values.st2chatops.image.tag | default .Chart.AppVersion) . }}"
imagePullPolicy: {{ .Values.st2chatops.image.pullPolicy | default .Values.image.pullPolicy }}
env:
- name: ST2_AUTH_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-st2-auth
key: username
- name: ST2_AUTH_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-st2-auth
key: password
envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
- secretRef:
name: {{ .Release.Name }}-st2chatops
ports:
- containerPort: 8081
# TODO: Add to st2chatops Docker image https://github.com/joelwallis/hubot-health for a little bit more reliable HTTP health endpoint check
readinessProbe:
tcpSocket:
port: 8081
initialDelaySeconds: 3
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8081
initialDelaySeconds: 10
periodSeconds: 30
resources:
{{ toYaml .Values.st2chatops.resources | indent 10 }}
{{- with .Values.st2chatops.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.st2chatops.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.st2chatops.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions templates/secrets_st2chatops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ if .Values.st2chatops.enabled -}}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-st2chatops
annotations:
description: Custom StackStorm chatops config, passed to hubot as ENV vars
labels:
app: st2chatops
tier: backend
vendor: stackstorm
support: {{ template "supportMethod" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
{{- range $env, $value := .Values.st2chatops.env }}
{{ $env }}: {{ $value | b64enc | quote }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions templates/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,30 @@ spec:
ports:
- protocol: TCP
port: 443

{{ if .Values.st2chatops.enabled -}}
---
kind: Service
apiVersion: v1
metadata:
name: {{ .Release.Name }}-st2chatops{{ template "enterpriseSuffix" . }}
annotations:
description: StackStorm st2chatops, - conversation-driven automation service exposed as hubot instance with predefined list of chat adapters
labels:
app: st2chatops
tier: backend
vendor: stackstorm
support: {{ template "supportMethod" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
app: st2chatops
support: {{ template "supportMethod" . }}
release: {{ .Release.Name }}
type: ClusterIP
ports:
- protocol: TCP
port: 8081
{{- end }}
31 changes: 31 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,37 @@ st2garbagecollector:
tolerations: []
affinity: {}

##
## StackStorm ChatOps (https://docs.stackstorm.com/chatops/index.html)
## As hubot can't be HA scaled properly, we deploy only single replica of st2chatops
##
st2chatops:
# Enable st2chatops (default: false)
enabled: false
# Custom hubot adapter ENV variables to pass through which will override st2chatops.env defaults.
# See https://github.com/StackStorm/st2chatops/blob/master/st2chatops.env
# for the full list of supported adapters and example ENV variables.
env:
HUBOT_ADAPTER: slack
HUBOT_SLACK_TOKEN: xoxb-CHANGE-ME-PLEASE
# Set custom generated st2chatops Docker image source
# Otherwise default https://hub.docker.com/r/stackstorm/st2chatops is used
image: {}
#repository: stackstorm
#name: st2chatops
#tag: "{{ .Chart.AppVersion }}"
#pullPolicy: Always
# Tested requested resource consumption for st2chatops & hubot in normal mode
# Please adjust based on your conscious choice
resources:
requests:
memory: "50Mi"
cpu: "5m"
# Additional advanced settings to control pod/deployment placement
nodeSelector: {}
tolerations: []
affinity: {}

##
## MongoDB HA configuration (3rd party chart dependency)
##
Expand Down

0 comments on commit 968816b

Please sign in to comment.