Skip to content

Commit 1235d19

Browse files
authored
Merge pull request #246 from cognifloyd/1sensor-cleanup
Improve one-sensor-per-pod UX: require "ref" in st2.packs.sensors
2 parents 8259d68 + f72f35d commit 1235d19

File tree

3 files changed

+32
-35
lines changed

3 files changed

+32
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Allow adding custom env variables to any Deployment or Job. (#120) (by @AngryDeveloper)
66
* Template the contents of st2.config and the values in st2chatops.env. This allows adding secrets defined elsewhere in values. (#249) (by @cognifloyd)
77
* Set default/sample RBAC config files to "" (empty string) to prevent adding them. This is needed because they cannot be removed by overriding the roles/mappings values. (#247) (by @cognifloyd)
8+
* Make configuring `stackstorm/sensor-mode=all-sensors-in-one-pod` more obvious by using `st2.packs.sensors` only for `one-sensor-per-pod`. `all-sensors-in-one-pod` mode now only uses values from `st2sensorcontainer`. (#246) (by @cognifloyd)
89

910
## v0.70.0
1011
* New feature: Shared packs volumes `st2.packs.volumes`. Allow using cluster-specific persistent volumes to store packs, virtualenvs, and (optionally) configs. This enables using `st2 pack install`. It even works with `st2packs` images in `st2.packs.images`. (#199) (by @cognifloyd)

templates/deployments.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,11 +1016,13 @@ spec:
10161016
tolerations: {{- toYaml . | nindent 8 }}
10171017
{{- end }}
10181018

1019-
{{- $one_sensor_per_pod := or (gt (len $.Values.st2.packs.sensors) 1) (index $.Values.st2.packs.sensors 0 "ref") }}
1020-
{{- range .Values.st2.packs.sensors }}
1019+
{{- $one_sensor_per_pod := not ($.Values.st2.packs.sensors | empty) }}
1020+
{{- range ($one_sensor_per_pod | ternary ($.Values.st2.packs.sensors) (until 1)) }}
10211021
{{- $sensor := omit $.Values.st2sensorcontainer "name" "ref" "postStartScript" }}
1022-
{{- range $key, $val := . }}
1023-
{{- $_ := set $sensor $key $val }}
1022+
{{- if $one_sensor_per_pod }}
1023+
{{- range $key, $val := . }}
1024+
{{- $_ := set $sensor $key $val }}
1025+
{{- end }}
10241026
{{- end }}
10251027
{{- $name := print "st2sensorcontainer" (include "hyphenPrefix" $sensor.name) }}
10261028
---
@@ -1106,9 +1108,9 @@ spec:
11061108
- --config-file=/etc/st2/st2.docker.conf
11071109
- --config-file=/etc/st2/st2.user.conf
11081110
- --single-sensor-mode
1109-
- --sensor-ref={{ $sensor.ref }}
1111+
- --sensor-ref={{ required "You must define `ref` for everything in st2.packs.sensors. This assigns each sensor to a pod." $sensor.ref }}
11101112
{{- end }}
1111-
{{- if .env }}
1113+
{{- if $sensor.env }}
11121114
env: {{- include "stackstorm-ha.customEnv" . | nindent 8 }}
11131115
{{- end }}
11141116
envFrom:

values.yaml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,33 +153,24 @@ st2:
153153
# (2) run one sensor per pod using st2.packs.sensors (here).
154154
# Each sensor node needs to be provided with proper partition information to share work with other sensor
155155
# nodes so that the same sensor does not run on different nodes.
156-
# Defaults come from st2sensorcontainer (see below), with per-sensor overrides defined here.
157-
sensors:
158-
# With only one sensor listed here, we use all-sensors-in-one-pod mode, unless that sensor has a `ref`.
159-
# To partition sensors with one-sensor-per-node, override st2.packs.sensors.
160-
# In one-sensor-per-pod mode, make sure each sensor here has both `name` and `ref` (which sensor to run in the pod).
161-
# NOTE: Do not modify this file.
162-
- name:
163-
livenessProbe: {}
164-
readinessProbe: {}
165-
annotations: {}
166-
resources:
167-
requests:
168-
memory: "100Mi"
169-
cpu: "50m"
170-
# Override default image settings (for now, only tag can be overridden)
171-
image: {}
172-
## Note that Helm templating is supported in this block!
173-
#tag: "{{ .Values.image.tag }}"
174-
# Additional advanced settings to control pod/deployment placement
175-
affinity: {}
176-
nodeSelector: {}
177-
tolerations: []
178-
env: {}
179-
# HTTP_PROXY: http://proxy:1234
180-
serviceAccount:
181-
attach: false
182-
# note: postStartScript is not valid here. Use st2sensorcontainer.postStartScript instead.
156+
# When this is empty (the default), the chart adds one pod to run all sensors.
157+
sensors: []
158+
# This is a list of sensor pods (stackstorm/sensor-mode=one-sensor-per-pod).
159+
# Each entry should have `name` (the pod name) and `ref` (which sensor to run in the pod).
160+
# Each entry can also include other pod settings (annotations, image, resources, etc).
161+
# These optional pod settings default to the values in st2sensorcontainer,
162+
# note: postStartScript is not valid in st2.packs.sensors. Use st2sensorcontainer.postStartScript instead.
163+
#
164+
# This example only defines name and ref, accepting all defaults in st2sensorcontainer:
165+
# - name: some-sensor-node
166+
# ref: some_pack.some_sensor
167+
#
168+
# This example also uses a custom image tag:
169+
# - name: another-sensor-node
170+
# ref: some_pack.another_sensor
171+
# image:
172+
# tag: 3.5.0-another_sensor-r1
173+
183174
# Import data into StackStorm's Key/Value datastore (https://docs.stackstorm.com/datastore.html)
184175
keyvalue:
185176
#- name: st2_version
@@ -560,8 +551,11 @@ st2actionrunner:
560551
postStartScript: ""
561552

562553
# https://docs.stackstorm.com/reference/ha.html#st2sensorcontainer
563-
# Please see st2.packs.sensors for each sensor instance's config.
564-
# This contains default settings for all sensor pods.
554+
# It is possible to run st2sensorcontainer(s) in one of these modes:
555+
# (1) run all sensors in one pod (1 deployment with 1 pod, the default); or
556+
# (2) run one sensor per pod using st2.packs.sensors (see above).
557+
# To use the default mode (all sensors in one pod), st2.packs.sensors must be empty.
558+
# For one-sensor-per-pod, define defaults here and add config for each sensor to st2.packs.sensors (above).
565559
st2sensorcontainer:
566560
resources:
567561
requests:

0 commit comments

Comments
 (0)