Skip to content

Commit 15abe2f

Browse files
committed
Templated Redis Connection String Formation. Replaced Etcd references with Redis.
1 parent 2012e99 commit 15abe2f

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
# Spin up minikube K8s cluster and run Helm chart & e2e tests on it
5151
helm-e2e:
5252
# 'large' 4 vCPUs & 15GB RAM CircleCI machine executor
53-
# required to deploy heavy 'stackstorm-ha' Helm release with RabbitMQ, MongoDB, etcd clusters and 25+ st2 Pods.
53+
# required to deploy heavy 'stackstorm-ha' Helm release with RabbitMQ, MongoDB, Redis clusters and 25+ st2 Pods.
5454
# https://circleci.com/docs/2.0/configuration-reference/#machine-executor-linux
5555
resource_class: large
5656
machine:

Chart.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ dependencies:
4040
version: 4.0.0
4141
repository: https://charts.bitnami.com/bitnami
4242
condition: external-dns.enabled
43-
- name: etcd
44-
version: 5.1.0
45-
repository: https://charts.bitnami.com/bitnami
46-
condition: etcd.enabled
4743
- name: redis
4844
version: 12.3.2
4945
repository: https://charts.bitnami.com/bitnami

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
K8s Helm Chart for running StackStorm cluster in HA mode.
55

66
It will install 2 replicas for each component of StackStorm microservices for redundancy, as well as backends like
7-
RabbitMQ HA, MongoDB HA Replicaset and etcd cluster that st2 replies on for MQ, DB and distributed coordination respectively.
7+
RabbitMQ HA, MongoDB HA Replicaset and Redis cluster that st2 replies on for MQ, DB and distributed coordination respectively.
88

99
It's more than welcome to fine-tune each component settings to fit specific availability/scalability demands.
1010

@@ -116,7 +116,7 @@ All the workflow engine processes will share the load and pick up more work if o
116116
Multiple st2notifier processes can run in active-active mode, using connections to RabbitMQ and MongoDB and generating triggers based on
117117
action execution completion as well as doing action rescheduling.
118118
In an HA deployment there must be a minimum of `2` replicas of st2notifier running, requiring a coordination backend,
119-
which in our case is `etcd`.
119+
which in our case is `Redis`.
120120

121121
### [st2sensorcontainer](https://docs.stackstorm.com/reference/ha.html#st2sensorcontainer)
122122
st2sensorcontainer manages StackStorm sensors: It starts, stops and restarts them as subprocesses.
@@ -143,7 +143,7 @@ st2:
143143
### [st2actionrunner](https://docs.stackstorm.com/reference/ha.html#st2actionrunner)
144144
Stackstorm workers that actually execute actions.
145145
`5` replicas for K8s Deployment are configured by default to increase StackStorm ability to execute actions without excessive queuing.
146-
Relies on `etcd` for coordination. This is likely the first thing to lift if you have a lot of actions
146+
Relies on `redis` for coordination. This is likely the first thing to lift if you have a lot of actions
147147
to execute per time period in your StackStorm cluster.
148148

149149
### [st2garbagecollector](https://docs.stackstorm.com/reference/ha.html#st2garbagecollector)
@@ -174,9 +174,9 @@ 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

177-
### [etcd](https://docs.stackstorm.com/latest/reference/ha.html#zookeeper-redis)
178-
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 bitnami Helm chart dependency [etcd](https://github.com/bitnami/charts/tree/master/bitnami/etcd).
177+
### [redis](https://docs.stackstorm.com/latest/reference/ha.html#zookeeper-redis)
178+
StackStorm employs redis sentinel as a distributed coordination backend, required for st2 cluster components to work properly in HA scenario.
179+
`3` node Redis cluster with Sentinel enabled is deployed via external bitnami Helm chart dependency [redis](https://github.com/bitnami/charts/tree/master/bitnami/redis).
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
@@ -220,7 +220,7 @@ Grab all logs for entire StackStorm cluster with dependent services in Helm rele
220220
kubectl logs -l release=<release-name>
221221
```
222222

223-
Grab all logs only for stackstorm backend services, excluding st2web and DB/MQ/etcd:
223+
Grab all logs only for stackstorm backend services, excluding st2web and DB/MQ/redis:
224224
```
225225
kubectl logs -l release=<release-name>,tier=backend
226226
```

templates/_helpers.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,19 @@ Create the name of the stackstorm-ha service account to use
7676
{{- end -}}
7777
{{- end -}}
7878
{{- end -}}
79+
80+
# Generate list of nodes for Redis with Sentinel connection string, based on number of replicas and service name
81+
{{- define "redis-nodes" -}}
82+
{{- if not .Values.redis.sentinel.enabled }}
83+
{{- fail "value for redis.sentinel.enabled MUST be true" }}
84+
{{- end }}
85+
{{- $replicas := (int (index .Values "redis" "cluster" "slaveCount")) }}
86+
{{- range $index0 := until $replicas -}}
87+
{{- if eq $index0 0 -}}
88+
{{ $.Release.Name }}-redis-node-{{ $index0 }}.{{ $.Release.Name }}-redis-headless:26379?sentinel=mymaster
89+
{{- else -}}
90+
&sentinel_fallback={{ $.Release.Name }}-redis-node-{{ $index0 }}.{{ $.Release.Name }}-redis-headless:26379
91+
{{- end -}}
92+
{{- end -}}
93+
{{- end -}}
94+

templates/configmaps_st2-conf.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ data:
2020
st2.docker.conf: |
2121
[auth]
2222
api_url = http://{{ .Release.Name }}-st2api{{ template "enterpriseSuffix" . }}:9101/
23-
{{- if index .Values "etcd" "enabled" }}
24-
[coordination]
25-
url = etcd://{{ index .Values "etcd" "fullnameOverride" }}:2379
26-
{{- end }}
2723
{{- if index .Values "redis" "enabled" }}
2824
[coordination]
29-
url = redis://{{ .Release.Name }}-redis-node-0.{{ .Release.Name }}-redis-headless:26379?sentinel=mymaster&sentinel_fallback={{ .Release.Name }}-redis-node-1.{{ .Release.Name }}-redis-headless:26379&sentinel_fallback={{ .Release.Name }}-redis-node-2.{{ .Release.Name }}-redis-headless:26379
25+
url = redis://{{ template "redis-nodes" $ }}
3026
{{- end }}
3127
{{- if index .Values "rabbitmq" "enabled" }}
3228
[messaging]

values.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,6 @@ rabbitmq:
508508
metrics:
509509
enabled: false
510510

511-
##
512-
## Etcd HA configuration (3rd party chart dependency)
513-
##
514-
## For values.yaml reference:
515-
## https://github.com/bitnami/charts/tree/master/bitnami/etcd
516-
##
517-
etcd:
518-
# Change to `false` to disable in-cluster ectd deployment.
519-
# Specify your external [coordination] connection parameters under st2.config
520-
enabled: false
521-
statefulset:
522-
replicaCount: 3
523-
fullnameOverride: etcd
524-
525511
##
526512
## Redis HA configuration (3rd party chart dependency)
527513
##
@@ -532,18 +518,20 @@ redis:
532518
# Change to `false` to disable in-cluster redis deployment.
533519
# Specify your external [coordination] connection parameters under st2.config
534520
enabled: true
521+
# By default the cluster is enabled for the subchart.
522+
# We just need replica count here to ensure it is HA
535523
cluster:
536-
enabled: true
537524
slaveCount: 3
538525
# ## Sentinel settings. Sentinel is enabled for better resiliency.
526+
# ## This is highly recommended as per tooz library documentation.
527+
# ## Hence, the chart requires the setting.
539528
# ## https://docs.openstack.org/tooz/latest/user/drivers.html#redis
540529
# ## https://github.com/bitnami/charts/tree/master/bitnami/redis#master-slave-with-sentinel
541530
sentinel:
542531
enabled: true
543532
networkPolicy:
544533
enabled: false
545534
usePassword: false
546-
#password: "PLoT2g3gvD"
547535
metrics:
548536
enabled: false
549537

0 commit comments

Comments
 (0)