Add postStart lifecycle hook (#315)
* Add postStart lifecycle hook * Update values.yaml Co-authored-by: Theron Voran <tvoran@users.noreply.github.com> Co-authored-by: Theron Voran <tvoran@users.noreply.github.com>
This commit is contained in:
parent
d755ad1ba0
commit
4215316818
3 changed files with 37 additions and 0 deletions
|
@ -159,6 +159,14 @@ spec:
|
|||
# to this pod while it's terminating
|
||||
"sleep {{ .Values.server.preStopSleepSeconds }} && kill -SIGTERM $(pidof vault)",
|
||||
]
|
||||
{{- if .Values.server.postStart }}
|
||||
postStart:
|
||||
exec:
|
||||
command:
|
||||
{{- range (.Values.server.postStart) }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.server.extraContainers }}
|
||||
{{ toYaml .Values.server.extraContainers | nindent 8}}
|
||||
{{- end }}
|
||||
|
|
|
@ -1048,3 +1048,24 @@ load _helpers
|
|||
yq '.spec.template.spec | .priorityClassName == "armaggeddon"' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# postStart
|
||||
@test "server/standalone-StatefulSet: postStart disabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
--show-only templates/server-statefulset.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].lifecycle.postStart' | tee /dev/stderr)
|
||||
[ "${actual}" = "null" ]
|
||||
}
|
||||
|
||||
@test "server/standalone-StatefulSet: postStart can be set" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
--show-only templates/server-statefulset.yaml \
|
||||
--set='server.postStart={/bin/sh,-c,sleep}' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].lifecycle.postStart.exec.command[0]' | tee /dev/stderr)
|
||||
[ "${actual}" = "/bin/sh" ]
|
||||
}
|
||||
|
|
|
@ -188,6 +188,14 @@ server:
|
|||
# Used to set the sleep time during the preStop step
|
||||
preStopSleepSeconds: 5
|
||||
|
||||
# Used to define commands to run after the pod is ready.
|
||||
# This can be used to automate processes such as initialization
|
||||
# or boostrapping auth methods.
|
||||
postStart: []
|
||||
# - /bin/sh
|
||||
# - -c
|
||||
# - /vault/userconfig/myscript/run.sh
|
||||
|
||||
# extraEnvironmentVars is a list of extra enviroment variables to set with the stateful set. These could be
|
||||
# used to include variables required for auto-unseal.
|
||||
extraEnvironmentVars: {}
|
||||
|
|
Loading…
Reference in a new issue