diff --git a/.gitignore b/.gitignore index 649516b7..56674120 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ charts *.lock +.DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index 824da6ec..73791ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Chart.yaml b/Chart.yaml index ad44b195..65538aee 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -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 @@ -12,6 +12,7 @@ keywords: - st2 - stackstorm - devops + - chatops - event-driven - auto-remediation - IFTTT diff --git a/README.md b/README.md index 356c22de..d0efddf3 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,8 @@ All the workflow engine processes will share the load and pick up more work if o > [Orquesta st2workflowengine](https://docs.stackstorm.com/orchestra/index.html) as a new native workflow engine. ### [st2scheduler](https://docs.stackstorm.com/reference/ha.html#st2scheduler) -TODO: Description TBD +`st2scheduler` is responsible for handling ingress action execution requests. +`2` replicas for K8s Deployment are configured by default to increase StackStorm scheduling throughput. ### [st2notifier](https://docs.stackstorm.com/reference/ha.html#st2notifier) Multiple st2notifier processes can run in active-active mode, using connections to RabbitMQ and MongoDB and generating triggers based on @@ -145,6 +146,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. diff --git a/templates/deployments.yaml b/templates/deployments.yaml index 9762d5ee..d52e4933 100644 --- a/templates/deployments.yaml +++ b/templates/deployments.yaml @@ -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 }} diff --git a/templates/secrets_st2chatops.yaml b/templates/secrets_st2chatops.yaml new file mode 100644 index 00000000..44ffbeeb --- /dev/null +++ b/templates/secrets_st2chatops.yaml @@ -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 }} diff --git a/templates/services.yaml b/templates/services.yaml index 78f964b8..b3eaa099 100644 --- a/templates/services.yaml +++ b/templates/services.yaml @@ -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 }} diff --git a/values.yaml b/values.yaml index 0580cbab..ddd26c4b 100644 --- a/values.yaml +++ b/values.yaml @@ -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) ##