Skip to content

Commit 1ff6e36

Browse files
authored
Merge pull request #220 from cognifloyd/configurable-stanley
Make system_user "stanley" configurable
2 parents 002c080 + b97f061 commit 1ff6e36

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Allow adding dnsPolicy and/or dnsConfig to all pods. (#201) (by @cognifloyd)
1616
* Move st2-config-vol volume definition and list of st2-config-vol volumeMounts to helpers to reduce duplication (#198) (by @cognifloyd)
1717
* Fix permissions for /home/stanley/.ssh/stanley_rsa using the postStart lifecycle hook (#219) (by @cognifloyd)
18+
* Make system_user configurable when using custom st2actionrunner images that do not provide stanley (#220) (by @cognifloyd)
1819

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

templates/configmaps_post-start-script.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ data:
1818
# see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
1919
post-start.sh: |
2020
#!/bin/bash
21-
mkdir -p /home/stanley/.ssh
22-
cp -L /home/stanley/.ssh{-key-vol,}/stanley_rsa
23-
chown -R stanley:stanley /home/stanley/.ssh/
24-
chmod 400 /home/stanley/.ssh/stanley_rsa
25-
chmod 500 /home/stanley/.ssh
21+
{{- $system_user := $.Values.st2.system_user.user }}
22+
{{- $ssh_key_file := tpl $.Values.st2.system_user.ssh_key_file $ }}
23+
{{- $ssh_key_file_name := base $ssh_key_file }}
24+
{{- $ssh_key_file_dir := dir $ssh_key_file }}
25+
mkdir -p {{ $ssh_key_file_dir }}
26+
cp -L {{ dir $ssh_key_file_dir }}/.ssh-key-vol/{{ $ssh_key_file_name }} {{ $ssh_key_file }}
27+
chown -R {{ $system_user }}:{{ $system_user }} {{ $ssh_key_file_dir }}
28+
chmod 400 {{ $ssh_key_file }}
29+
chmod 500 {{ $ssh_key_file_dir }}

templates/configmaps_st2-conf.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ data:
1919
st2.docker.conf: |
2020
[auth]
2121
api_url = http://{{ .Release.Name }}-st2api:9101/
22+
[system_user]
23+
user = {{ .Values.st2.system_user.user }}
24+
ssh_key_file = {{ tpl .Values.st2.system_user.ssh_key_file . }}
2225
{{- if index .Values "redis" "enabled" }}
2326
[coordination]
2427
url = redis://{{ template "redis-nodes" $ }}

templates/deployments.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ spec:
10201020
volumeMounts:
10211021
{{- include "st2-config-volume-mounts" . | nindent 8 }}
10221022
- name: st2-ssh-key-vol
1023-
mountPath: /home/stanley/.ssh-key-vol/
1023+
mountPath: {{ tpl .Values.st2.system_user.ssh_key_file . | dir | dir }}/.ssh-key-vol/
10241024
{{- if .Values.st2.datastore_crypto_key }}
10251025
- name: st2-encryption-key-vol
10261026
mountPath: /etc/st2/keys
@@ -1061,7 +1061,7 @@ spec:
10611061
secretName: {{ .Release.Name }}-st2-ssh
10621062
items:
10631063
- key: private_key
1064-
path: stanley_rsa
1064+
path: {{ tpl .Values.st2.system_user.ssh_key_file . | base }}
10651065
# 0400 file permission
10661066
mode: 256
10671067
{{- if .Values.st2.packs.images }}
@@ -1268,7 +1268,7 @@ spec:
12681268
- name: st2client-config-vol
12691269
mountPath: /root/.st2/
12701270
- name: st2-ssh-key-vol
1271-
mountPath: /home/stanley/.ssh-key-vol/
1271+
mountPath: {{ tpl .Values.st2.system_user.ssh_key_file . | dir | dir }}/.ssh-key-vol/
12721272
{{- if .Values.st2.datastore_crypto_key }}
12731273
- name: st2-encryption-key-vol
12741274
mountPath: /etc/st2/keys
@@ -1329,7 +1329,7 @@ spec:
13291329
secretName: {{ .Release.Name }}-st2-ssh
13301330
items:
13311331
- key: private_key
1332-
path: stanley_rsa
1332+
path: {{ tpl .Values.st2.system_user.ssh_key_file . | base }}
13331333
# 0400 file permission
13341334
mode: 256
13351335
{{- if .Values.st2.packs.images }}

values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ st2:
6464
[api]
6565
allow_origin = '*'
6666
67+
# This mirrors the [system_user] section of st2.conf, but makes the values available for helm templating.
68+
# If you change the user, you must provide a customized st2actionrunner image that includes your user.
69+
system_user:
70+
user: stanley
71+
# templating is allowed for this key
72+
ssh_key_file: "/home/{{ .Values.st2.system_user.user }}/.ssh/stanley_rsa"
73+
6774
# Custom pack configs and image settings.
6875
#
6976
# By default, system packs are available. However, since 'st2 pack install' cannot be run in the k8s cluster,

0 commit comments

Comments
 (0)