Skip to content

Commit eee2803

Browse files
authored
Merge pull request #169 from arms11/redis-as-coordination
Setting redis as coordination backend
2 parents e373c72 + fed32da commit eee2803

File tree

8 files changed

+73
-21
lines changed

8 files changed

+73
-21
lines changed

.circleci/config.yml

+1-1
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:

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## In Development
44

5+
## v0.51.0
6+
* Added Redis with Sentinel to replace etcd as a coordination backend (#169)
7+
58
## v0.50.0
69
* Drop Helm `v2` support and fully migrate to Helm `v3` (#163)
710
* Switch dependencies from deprecated `helm/charts` to new Bitnami Subcharts (#163)

Chart.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
# StackStorm version which refers to Docker images tag
33
appVersion: 3.4dev
44
name: stackstorm-ha
5-
version: 0.50.0
5+
version: 0.51.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
@@ -40,7 +40,8 @@ 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
43+
- name: redis
44+
version: 12.3.2
4545
repository: https://charts.bitnami.com/bitnami
46-
condition: etcd.enabled
46+
condition: redis.enabled
47+

README.md

+7-7
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

+18
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,21 @@ 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+
{{- $master_name := (index .Values "redis" "sentinel" "masterSet") }}
87+
{{- $sentinel_port := (index .Values "redis" "sentinel" "port") }}
88+
{{- range $index0 := until $replicas -}}
89+
{{- if eq $index0 0 -}}
90+
{{ $.Release.Name }}-redis-node-{{ $index0 }}.{{ $.Release.Name }}-redis-headless:{{ $sentinel_port }}?sentinel={{ $master_name }}
91+
{{- else -}}
92+
&sentinel_fallback={{ $.Release.Name }}-redis-node-{{ $index0 }}.{{ $.Release.Name }}-redis-headless:{{ $sentinel_port }}
93+
{{- end -}}
94+
{{- end -}}
95+
{{- end -}}
96+

templates/configmaps_st2-conf.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +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" }}
23+
{{- if index .Values "redis" "enabled" }}
2424
[coordination]
25-
url = etcd://{{ index .Values "etcd" "fullnameOverride" }}:2379
25+
url = redis://{{ template "redis-nodes" $ }}
2626
{{- end }}
2727
{{- if index .Values "rabbitmq" "enabled" }}
2828
[messaging]

tests/st2tests.sh

+17
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,20 @@ load "${BATS_HELPERS_DIR}/bats-file/load.bash"
5757
assert_success
5858
assert_line --partial 'chatops.notify'
5959
}
60+
61+
@test 'st2 key/value operations are functional' {
62+
run st2 key set foo bar
63+
assert_success
64+
65+
run st2 key get foo
66+
assert_success
67+
assert_line --partial 'bar'
68+
69+
run st2 key delete foo
70+
assert_line --partial '"foo" has been successfully deleted'
71+
assert_success
72+
73+
run st2 key get foo
74+
assert_line --partial '"foo" is not found'
75+
assert_failure
76+
}

values.yaml

+20-7
Original file line numberDiff line numberDiff line change
@@ -509,18 +509,31 @@ rabbitmq:
509509
enabled: false
510510

511511
##
512-
## Etcd HA configuration (3rd party chart dependency)
512+
## Redis HA configuration (3rd party chart dependency)
513513
##
514514
## For values.yaml reference:
515-
## https://github.com/bitnami/charts/tree/master/bitnami/etcd
515+
## https://github.com/bitnami/charts/tree/master/bitnami/redis
516516
##
517-
etcd:
518-
# Change to `false` to disable in-cluster ectd deployment.
517+
redis:
518+
# Change to `false` to disable in-cluster redis deployment.
519519
# Specify your external [coordination] connection parameters under st2.config
520520
enabled: true
521-
statefulset:
522-
replicaCount: 3
523-
fullnameOverride: etcd
521+
# By default the cluster is enabled for the subchart.
522+
# We just need replica count here to ensure it is HA
523+
cluster:
524+
slaveCount: 3
525+
# ## 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.
528+
# ## https://docs.openstack.org/tooz/latest/user/drivers.html#redis
529+
# ## https://github.com/bitnami/charts/tree/master/bitnami/redis#master-slave-with-sentinel
530+
sentinel:
531+
enabled: true
532+
networkPolicy:
533+
enabled: false
534+
usePassword: false
535+
metrics:
536+
enabled: false
524537

525538
##
526539
## External DNS configuration (3rd party chart dependency)

0 commit comments

Comments
 (0)