Skip to content

Commit a579799

Browse files
committed
Make st2.packs.sensors pull default values from st2sensorcontainer
1 parent 834c478 commit a579799

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Make system_user configurable when using custom st2actionrunner images that do not provide stanley (#220) (by @cognifloyd)
1919
* Allow providing scripts in values for use in lifecycle postStart hooks of all deployments. (#206) (by @cognifloyd)
2020
* Add preRegisterContentCommand in an initContainer for register-content job to run last-minute content customizations (#213) (by @cognifloyd)
21+
* Minimize required sensor config by using default values from st2sensorcontainer for each sensor in st2.packs.sensors (#???) (by @cognifloyd)
2122

2223
## v0.60.0
2324
* Switch st2 version to `v3.5dev` as a new latest development version (#187)

templates/deployments.yaml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -982,13 +982,15 @@ spec:
982982
{{- end }}
983983

984984
{{- range .Values.st2.packs.sensors }}
985+
{{- $sensor := deepCopy $.st2sensorcontainer | mustMergeOverwrite . }}
986+
{{- $name := print "st2sensorcontainer" (include "hyphenPrefix" $sensor.name) }}
985987
---
986988
apiVersion: apps/v1
987989
kind: Deployment
988990
metadata:
989-
name: {{ $.Release.Name }}-st2sensorcontainer{{ template "hyphenPrefix" .name }}
991+
name: {{ $.Release.Name }}-{{ $name }}
990992
labels:
991-
app: st2sensorcontainer{{ template "hyphenPrefix" .name }}
993+
app: {{ $name }}
992994
tier: backend
993995
vendor: stackstorm
994996
chart: {{ $.Chart.Name }}-{{ $.Chart.Version }}
@@ -997,7 +999,7 @@ metadata:
997999
spec:
9981000
selector:
9991001
matchLabels:
1000-
app: st2sensorcontainer{{ template "hyphenPrefix" .name }}
1002+
app: {{ $name }}
10011003
release: {{ $.Release.Name }}
10021004
# https://docs.stackstorm.com/reference/ha.html#st2sensorcontainer
10031005
# It is possible to run st2sensorcontainer in HA mode by running one process on each compute instance. Each sensor node needs to be
@@ -1007,7 +1009,7 @@ spec:
10071009
template:
10081010
metadata:
10091011
labels:
1010-
app: st2sensorcontainer{{ template "hyphenPrefix" .name }}
1012+
app: {{ $name }}
10111013
tier: backend
10121014
vendor: stackstorm
10131015
chart: {{ $.Chart.Name }}-{{ $.Chart.Version }}
@@ -1020,8 +1022,8 @@ spec:
10201022
{{- if $.Values.st2sensorcontainer.postStartScript }}
10211023
checksum/post-start-script: {{ $.Values.st2sensorcontainer.postStartScript | sha256sum }}
10221024
{{- end }}
1023-
{{- if .annotations }}
1024-
{{- toYaml .annotations | nindent 8 }}
1025+
{{- if $sensor.annotations }}
1026+
{{- toYaml $sensor.annotations | nindent 8 }}
10251027
{{- end }}
10261028
spec:
10271029
imagePullSecrets:
@@ -1038,26 +1040,26 @@ spec:
10381040
{{- include "packs-initContainers" $ | nindent 6 }}
10391041
{{- end }}
10401042
containers:
1041-
- name: st2sensorcontainer{{ template "hyphenPrefix" .name }}
1042-
image: '{{ template "imageRepository" $ }}/st2sensorcontainer:{{ tpl (.image.tag | default $.Values.image.tag) $ }}'
1043+
- name: {{ $name }}
1044+
image: '{{ template "imageRepository" $ }}/st2sensorcontainer:{{ tpl ($sensor.image.tag | default $.Values.image.tag) $ }}'
10431045
imagePullPolicy: {{ $.Values.image.pullPolicy }}
1044-
{{- with .readinessProbe }}
1046+
{{- with $sensor.readinessProbe }}
10451047
# Probe to check if app is running. Failure will lead to a pod restart.
10461048
readinessProbe:
10471049
{{- toYaml . | nindent 10 }}
10481050
{{- end }}
1049-
{{- with .livenessProbe }}
1051+
{{- with $sensor.livenessProbe }}
10501052
livenessProbe:
10511053
{{- toYaml . | nindent 10 }}
10521054
{{- end }}
1053-
{{- if .ref }}
1055+
{{- if $sensor.ref }}
10541056
command:
10551057
- /opt/stackstorm/st2/bin/st2sensorcontainer
10561058
- --config-file=/etc/st2/st2.conf
10571059
- --config-file=/etc/st2/st2.docker.conf
10581060
- --config-file=/etc/st2/st2.user.conf
10591061
- --single-sensor-mode
1060-
- --sensor-ref={{ .ref }}
1062+
- --sensor-ref={{ $sensor.ref }}
10611063
{{- end }}
10621064
envFrom:
10631065
- configMapRef:
@@ -1087,8 +1089,8 @@ spec:
10871089
command: ["/bin/bash", "/post-start.sh"]
10881090
{{- end }}
10891091
resources:
1090-
{{- toYaml .resources | nindent 10 }}
1091-
{{- if .serviceAccount.attach }}
1092+
{{- toYaml $sensor.resources | nindent 10 }}
1093+
{{- if $sensor.serviceAccount.attach }}
10921094
serviceAccountName: {{ template "stackstorm-ha.serviceAccountName" $ }}
10931095
{{- end }}
10941096
volumes:
@@ -1115,13 +1117,13 @@ spec:
11151117
{{- with $.Values.dnsConfig }}
11161118
dnsConfig: {{- toYaml . | nindent 8 }}
11171119
{{- end }}
1118-
{{- with .nodeSelector }}
1120+
{{- with $sensor.nodeSelector }}
11191121
nodeSelector: {{- toYaml . | nindent 8 }}
11201122
{{- end }}
1121-
{{- with .affinity }}
1123+
{{- with $sensor.affinity }}
11221124
affinity: {{- toYaml . | nindent 8 }}
11231125
{{- end }}
1124-
{{- with .tolerations }}
1126+
{{- with $sensor.tolerations }}
11251127
tolerations: {{- toYaml . | nindent 8 }}
11261128
{{- end }}
11271129
{{- end }}

values.yaml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,14 @@ st2:
100100
# It is possible to run st2sensorcontainer in HA mode by running one process on each compute instance.
101101
# Each sensor node needs to be provided with proper partition information to share work with other sensor
102102
# nodes so that the same sensor does not run on different nodes.
103+
# Default values are taken from st2sensorcontainer.* (see below)
103104
sensors:
104105
# Specify default container that executes all sensors.
105106
# To partition sensors with one sensor per node, override st2.packs.sensors.
106107
# NOTE: Do not modify this file.
107108
- name:
108-
livenessProbe: {}
109-
readinessProbe: {}
110-
annotations: {}
111-
resources:
112-
requests:
113-
memory: "100Mi"
114-
cpu: "50m"
115-
# Override default image settings (for now, only tag can be overridden)
116-
image: {}
117-
## Note that Helm templating is supported in this block!
118-
#tag: "{{ .Values.image.tag }}"
119-
# Additional advanced settings to control pod/deployment placement
120-
affinity: {}
121-
nodeSelector: {}
122-
tolerations: []
123-
serviceAccount:
124-
attach: false
109+
# defaults are defined in st2sensorcontainer, with overrides defined here in st2.packs.sensors. For example:
110+
#annotations: {"someSensorAnnotation": Overrride an annotation per-sensor like this.}
125111
# note: postStartScript is not valid here. Use st2sensorcontainer.postStartScript instead.
126112
# Import data into StackStorm's Key/Value datastore (https://docs.stackstorm.com/datastore.html)
127113
keyvalue:
@@ -482,8 +468,25 @@ st2actionrunner:
482468

483469
# https://docs.stackstorm.com/reference/ha.html#st2sensorcontainer
484470
# Please see st2.packs.sensors for each sensor instance's config.
485-
# This contains settings that are common to all sensor pods.
471+
# This contains default settings for all sensor pods.
486472
st2sensorcontainer:
473+
resources:
474+
requests:
475+
memory: "100Mi"
476+
cpu: "50m"
477+
# Override default image settings (for now, only tag can be overridden)
478+
image: {}
479+
## Note that Helm templating is supported in this block!
480+
#tag: "{{ .Values.image.tag }}"
481+
livenessProbe: {}
482+
readinessProbe: {}
483+
annotations: {}
484+
# Additional advanced settings to control pod/deployment placement
485+
affinity: {}
486+
nodeSelector: {}
487+
tolerations: []
488+
serviceAccount:
489+
attach: false
487490
# postStartScript is optional. It has the contents of a bash script.
488491
# k8s will run the script in the st2 container in parallel with the ENTRYPOINT.
489492
# The pod will not be marked as "running" until this script completes successfully.

0 commit comments

Comments
 (0)