Skip to content

Commit e373c72

Browse files
authored
Merge pull request #163 from christopher-russell/master
Migrate to Helm v3, Change dependencies from deprecated official helm charts to Bitnami charts
2 parents a841b54 + 0d1e38d commit e373c72

File tree

11 files changed

+181
-98
lines changed

11 files changed

+181
-98
lines changed

.circleci/config.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ version: 2.1
44
orbs:
55
# https://circleci.com/orbs/registry/orb/circleci/kubernetes
66
kubernetes: circleci/[email protected]
7-
# Pins Helm to v2.x
8-
# TODO: Consider upgrading Helm to v3.0 (https://github.com/StackStorm/stackstorm-ha/issues/98)
97
# https://circleci.com/orbs/registry/orb/circleci/helm
10-
helm: circleci/helm@0.2.3
8+
helm: circleci/helm@1.1.1
119
# https://circleci.com/orbs/registry/orb/ccpgames/minikube
1210
minikube: ccpgames/[email protected]
1311

@@ -16,15 +14,13 @@ jobs:
1614
helm-lint:
1715
working_directory: ~/stackstorm-ha
1816
docker:
19-
# Pin Helm to v2.x, see https://github.com/StackStorm/stackstorm-ha/issues/98
20-
- image: lachlanevenson/k8s-helm:v2.16.9
17+
- image: lachlanevenson/k8s-helm:v3.3.4
2118
steps:
2219
- checkout
2320
- run:
2421
name: Prepare Helm
2522
command: |
2623
set -x
27-
helm init --stable-repo-url https://charts.helm.sh/stable --client-only
2824
helm dependency update
2925
- run:
3026
name: Helm Lint Check
@@ -65,33 +61,33 @@ jobs:
6561
- kubernetes/install
6662
- minikube/minikube-install:
6763
# https://github.com/kubernetes/minikube/releases
68-
version: v1.10.1
64+
version: v1.15.1
6965
- run:
7066
name: Install dependencies
7167
command: |
7268
sudo apt update || true
7369
# K8s 1.18 requires conntrack
7470
# See: https://github.com/kubernetes/minikube/issues/7179
7571
sudo apt install -y conntrack
72+
- run:
73+
name: Install Helm v3
74+
command: curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
7675
- run:
7776
name: Create new K8s cluster
7877
command: sudo -E minikube start --vm-driver=none
7978
environment:
8079
CHANGE_MINIKUBE_NONE_USER: true
81-
- run:
82-
name: Helm Init
83-
command: |
84-
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
85-
helm init --stable-repo-url https://charts.helm.sh/stable
8680
- run:
8781
name: Update stackstorm-ha chart dependencies
8882
command: helm dependency update
8983
- run:
9084
name: Helm install stackstorm-ha chart
91-
command: helm install --timeout 600 --debug --wait --name stackstorm-ha .
85+
command: helm install --timeout 10m0s --debug --wait --name-template stackstorm-ha .
9286
- run:
87+
# once https://github.com/helm/community/pull/165 is merged we will need to add the parallelism flag back into the
88+
# below command
9389
name: Helm test
94-
command: helm test stackstorm-ha --parallel --cleanup
90+
command: helm test stackstorm-ha
9591
- run:
9692
when: always
9793
name: Show created K8s resources

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## In Development
44

5+
## v0.50.0
6+
* Drop Helm `v2` support and fully migrate to Helm `v3` (#163)
7+
* Switch dependencies from deprecated `helm/charts` to new Bitnami Subcharts (#163)
8+
59
## v0.41.0
610
* Fix Helm 2 repository location to a new working URL https://charts.helm.sh/stable (#164) (by @manisha-tanwar)
711

Chart.yaml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
apiVersion: v1
2-
# Update StackStorm version here to rely on other Docker images tags
1+
apiVersion: v2
2+
# StackStorm version which refers to Docker images tag
33
appVersion: 3.4dev
44
name: stackstorm-ha
5-
version: 0.41.0
5+
version: 0.50.0
66
description: StackStorm K8s Helm Chart, optimized for running StackStorm in HA environment.
77
home: https://stackstorm.com/
88
icon: https://landscape.cncf.io/logos/stack-storm.svg
@@ -27,3 +27,20 @@ details:
2727
This Helm chart is a fully installable app that codifies StackStorm cluster deployment optimized for HA and K8s environment.
2828
RabbitMQ-HA, MongoDB-HA clusters and coordination backend st2 relies on will be deployed as 3rd party chart dependencies.
2929
For configuration details please check default values.yaml and README.
30+
dependencies:
31+
- name: rabbitmq
32+
version: 8.0.2
33+
repository: https://charts.bitnami.com/bitnami
34+
condition: rabbitmq.enabled
35+
- name: mongodb
36+
version: 10.0.1
37+
repository: https://charts.bitnami.com/bitnami
38+
condition: mongodb.enabled
39+
- name: external-dns
40+
version: 4.0.0
41+
repository: https://charts.bitnami.com/bitnami
42+
condition: external-dns.enabled
43+
- name: etcd
44+
version: 5.1.0
45+
repository: https://charts.bitnami.com/bitnami
46+
condition: etcd.enabled

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It's more than welcome to fine-tune each component settings to fit specific avai
1010

1111
## Requirements
1212
* [Kubernetes](https://kubernetes.io/docs/setup/pick-right-solution/) cluster
13-
* [Helm](https://docs.helm.sh/using_helm/#install-helm) and [Tiller](https://docs.helm.sh/using_helm/#initialize-helm-and-install-tiller) `v2.x`
13+
* [Helm](https://docs.helm.sh/using_helm/#install-helm) `v3.x`
1414

1515
## Usage
1616
1) Edit `values.yaml` with configuration for the StackStorm HA K8s cluster.
@@ -157,10 +157,10 @@ StackStorm ChatOps service, based on hubot engine, custom stackstorm integration
157157
Due to Hubot limitation, st2chatops doesn't provide mechanisms to guarantee high availability and so only single `1` node of st2chatops is deployed.
158158
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.
159159

160-
### [MongoDB HA ReplicaSet](https://github.com/helm/charts/tree/master/stable/mongodb-replicaset)
161-
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/).
160+
### [MongoDB ReplicaSet](https://github.com/bitnami/charts/tree/master/bitnami/mongodb)
161+
StackStorm works with MongoDB as a database engine. External Helm Chart is used to configure MongoDB [ReplicaSet](https://docs.mongodb.com/manual/tutorial/deploy-replica-set/).
162162
By default `3` nodes (1 primary and 2 secondaries) of MongoDB are deployed via K8s StatefulSet.
163-
For more advanced MongoDB configuration, refer to official [mongodb-replicaset](https://github.com/helm/charts/tree/master/stable/mongodb-replicaset)
163+
For more advanced MongoDB configuration, refer to bitnami [mongodb](https://github.com/bitnami/charts/tree/master/bitnami/mongodb)
164164
Helm chart settings, which might be fine-tuned via `values.yaml`.
165165

166166
The deployment of MongoDB to the k8s cluster can be disabled by setting the mongodb-ha.enabled key in values.yaml to false. *Note: Stackstorm relies heavily on connections to a MongoDB instance. If the in-cluster deployment of MongoDB is disabled, a connection to an external instance of MongoDB must be configured. The st2.config key in values.yaml provides a way to configure stackstorm. See [Configure MongoDB](https://docs.stackstorm.com/install/config/config.html#configure-mongodb) for configuration details.*
@@ -169,14 +169,14 @@ The deployment of MongoDB to the k8s cluster can be disabled by setting the mong
169169
RabbitMQ is a message bus StackStorm relies on for inter-process communication and load distribution.
170170
External Helm Chart is used to deploy [RabbitMQ cluster](https://www.rabbitmq.com/clustering.html) in Highly Available mode.
171171
By default `3` nodes of RabbitMQ are deployed via K8s StatefulSet.
172-
For more advanced RabbitMQ configuration, please refer to official [rabbitmq-ha](https://github.com/helm/charts/tree/master/stable/rabbitmq-ha)
172+
For more advanced RabbitMQ configuration, please refer to bitnami [rabbitmq](https://github.com/bitnami/charts/tree/master/bitnami/rabbitmq)
173173
Helm chart repository, - all settings could be overridden via `values.yaml`.
174174

175175
The deployment of RabbitMQ to the k8s cluster can be disabled by setting the rabbitmq-ha.enabled key in values.yaml to false. *Note: Stackstorm relies heavily on connections to a RabbitMQ instance. If the in-cluster deployment of RabbitMQ is disabled, a connection to an external instance of RabbitMQ must be configured. The st2.config key in values.yaml provides a way to configure stackstorm. See [Configure RabbitMQ](https://docs.stackstorm.com/install/config/config.html#configure-rabbitmq) for configuration details.*
176176

177177
### [etcd](https://docs.stackstorm.com/latest/reference/ha.html#zookeeper-redis)
178178
StackStorm employs etcd as a distributed coordination backend, required for st2 cluster components to work properly in HA scenario.
179-
`3` node Raft cluster is deployed via external official Helm chart dependency [etcd-operator](https://github.com/helm/charts/tree/master/stable/etcd-operator).
179+
`3` node Raft cluster is deployed via external bitnami Helm chart dependency [etcd](https://github.com/bitnami/charts/tree/master/bitnami/etcd).
180180
As any other Helm dependency, it's possible to further configure it for specific scaling needs via `values.yaml`.
181181

182182
## Install custom st2 packs in the cluster

conf/rabbit-definition.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"users": [
3+
{
4+
"name": {{ .Values.rabbitmq.auth.username | quote }},
5+
"password": {{ .Values.rabbitmq.auth.password | quote }},
6+
"tags": "administrator"
7+
}
8+
],
9+
"permissions": [
10+
{
11+
"user": {{ .Values.rabbitmq.auth.username | quote }},
12+
"vhost": {{ .Values.rabbitmq.ingress.path | quote }},
13+
"configure": ".*",
14+
"write": ".*",
15+
"read": ".*"
16+
}
17+
],
18+
"vhosts": [
19+
{
20+
"name": "/"
21+
}
22+
],
23+
"policies": [
24+
{
25+
"vhost":"/",
26+
"name":"ha",
27+
"pattern":"",
28+
"definition": {
29+
"ha-mode":"all",
30+
"ha-sync-mode": "automatic",
31+
"ha-sync-batch-size":10
32+
}
33+
}
34+
]
35+
}

requirements.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

templates/_helpers.tpl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Create the name of the stackstorm-ha service account to use
5050
# Allow calling helpers from nested sub-chart
5151
# https://stackoverflow.com/a/52024583/4533625
5252
# https://github.com/helm/helm/issues/4535#issuecomment-477778391
53-
# Usage: "{{ include "nested" (list . "mongodb-ha" "mongodb-replicaset.fullname") }}"
53+
# Usage: "{{ include "nested" (list . "mongodb" "mongodb.fullname") }}"
5454
{{- define "nested" }}
5555
{{- $dot := index . 0 }}
5656
{{- $subchart := index . 1 | splitList "." }}
@@ -63,11 +63,16 @@ Create the name of the stackstorm-ha service account to use
6363
{{- end }}
6464

6565
# Generate comma-separated list of nodes for MongoDB-HA connection string, based on number of replicas and service name
66-
{{- define "mongodb-ha-nodes" -}}
67-
{{- $replicas := (int (index .Values "mongodb-ha" "replicas")) }}
68-
{{- $mongo_fullname := include "nested" (list $ "mongodb-ha" "mongodb-replicaset.fullname") }}
69-
{{- range $index0 := until $replicas -}}
70-
{{- $index1 := $index0 | add1 -}}
71-
{{ $mongo_fullname }}-{{ $index0 }}.{{ $mongo_fullname }}{{ if ne $index1 $replicas }},{{ end }}
66+
{{- define "mongodb-nodes" -}}
67+
{{- $replicas := (int (index .Values "mongodb" "replicaCount")) }}
68+
{{- $architecture := (index .Values "mongodb" "architecture" ) }}
69+
{{- $mongo_fullname := include "nested" (list $ "mongodb" "mongodb.fullname") }}
70+
{{- range $index0 := until $replicas -}}
71+
{{- $index1 := $index0 | add1 -}}
72+
{{- if eq $architecture "replicaset" }}
73+
{{- $mongo_fullname }}-{{ $index0 }}.{{ $mongo_fullname }}-headless{{ if ne $index1 $replicas }},{{ end }}
74+
{{- else }}
75+
{{- $mongo_fullname }}-{{ $index0 }}.{{ $mongo_fullname }}{{ if ne $index1 $replicas }},{{ end }}
7276
{{- end -}}
7377
{{- end -}}
78+
{{- end -}}

templates/configmaps_st2-conf.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,25 @@ data:
2020
st2.docker.conf: |
2121
[auth]
2222
api_url = http://{{ .Release.Name }}-st2api{{ template "enterpriseSuffix" . }}:9101/
23-
{{- if index .Values "etcd-operator" "enabled" }}
23+
{{- if index .Values "etcd" "enabled" }}
2424
[coordination]
25-
url = etcd://{{ index .Values "etcd-operator" "etcdCluster" "name" }}-client:2379
25+
url = etcd://{{ index .Values "etcd" "fullnameOverride" }}:2379
2626
{{- end }}
27-
{{- if index .Values "rabbitmq-ha" "enabled" }}
27+
{{- if index .Values "rabbitmq" "enabled" }}
2828
[messaging]
29-
url = amqp://{{ required "rabbitmq-ha.rabbitmqUsername is required!" (index .Values "rabbitmq-ha" "rabbitmqUsername") }}:{{ required "rabbitmq-ha.rabbitmqPassword is required!" (index .Values "rabbitmq-ha" "rabbitmqPassword") }}@{{ .Release.Name }}-rabbitmq-ha-discovery:5672
29+
url = amqp://{{ required "rabbitmq.auth.username is required!" (index .Values "rabbitmq" "auth" "username") }}:{{ required "rabbitmq.auth.password is required!" (index .Values "rabbitmq" "auth" "password") }}@{{ .Release.Name }}-rabbitmq:5672{{ required "rabbitmq.ingress.path is required!" (index .Values "rabbitmq" "ingress" "path") }}
3030
{{- end }}
31-
{{- if index .Values "mongodb-ha" "enabled" }}
31+
{{- if index .Values "mongodb" "enabled" }}
3232
[database]
33-
{{- if index .Values "mongodb-ha" "auth" "enabled" }}
34-
host = mongodb://{{ template "mongodb-ha-nodes" $ }}/?authSource=admin&replicaSet={{ index .Values "mongodb-ha" "replicaSetName" }}
35-
username = {{ required "mongodb-ha.auth.adminUser is required!" (index .Values "mongodb-ha" "auth" "adminUser") }}
36-
password = {{ required "mongodb-ha.auth.adminPassword is required!" (index .Values "mongodb-ha" "auth" "adminPassword") }}
33+
{{- if index .Values "mongodb" "auth" "enabled" }}
34+
host = mongodb://{{ template "mongodb-nodes" $ }}/{{ required "mongodb.auth.database is required!" (index .Values "mongodb" "auth" "database") }}?authSource={{ required "mongodb.auth.database is required!" (index .Values "mongodb" "auth" "database") }}&replicaSet={{ index .Values "mongodb" "replicaSetName" }}
35+
username = {{ required "mongodb.auth.username is required!" (index .Values "mongodb" "auth" "username") }}
36+
password = {{ required "mongodb.auth.password is required!" (index .Values "mongodb" "auth" "password") }}
37+
db_name = {{ required "mongodb.auth.database is required!" (index .Values "mongodb" "auth" "database") }}
3738
{{- else }}
38-
host = mongodb://{{ template "mongodb-ha-nodes" $ }}/?replicaSet={{ index .Values "mongodb-ha" "replicaSetName" }}
39+
host = mongodb://{{ template "mongodb-nodes" $ }}/?replicaSet={{ index .Values "mongodb" "replicaSetName" }}
3940
{{- end }}
40-
port = {{ index .Values "mongodb-ha" "port" }}
41+
port = {{ index .Values "mongodb" "service" "port" }}
4142
{{- end }}
4243
{{- if .Values.secrets.st2.datastore_crypto_key }}
4344
[keyvalue]

templates/secrets_rabbitmq.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This configuration is a workaround to https://github.com/bitnami/charts/issues/4635
2+
# This code block should be dropped once the above issue is resolved and definitions can be defined as shown in
3+
# https://github.com/bitnami/charts/tree/master/bitnami/rabbitmq#load-definitions
4+
---
5+
apiVersion: v1
6+
kind: Secret
7+
metadata:
8+
name: {{ .Release.Name }}-rabbitmq-definitions
9+
annotations:
10+
description: A rabbitmq definition which will be loaded by the rabbitmq subchart to enable mirroring for Rabbit HA
11+
labels:
12+
app: st2
13+
tier: backend
14+
vendor: stackstorm
15+
support: {{ template "supportMethod" . }}
16+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
17+
release: "{{ .Release.Name }}"
18+
heritage: "{{ .Release.Service }}"
19+
type: Opaque
20+
data:
21+
rabbitmq-definitions.json: {{ tpl (.Files.Get "conf/rabbit-definition.conf") . | b64enc }}

templates/tests/st2tests-pod.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ metadata:
1212
heritage: {{ .Release.Service }}
1313
annotations:
1414
"helm.sh/hook": test-success
15+
"helm.sh/hook-delete-policy": hook-succeeded
1516
spec:
1617
{{- if .Values.enterprise.enabled }}
1718
imagePullSecrets:

0 commit comments

Comments
 (0)