support exec in server liveness probe (#971)

Co-authored-by: Theron Voran <tvoran@users.noreply.github.com>
This commit is contained in:
Thy Ton 2023-11-09 13:38:59 -08:00 committed by GitHub
parent 36dafa02c0
commit 2bb6994dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 1 deletions

View file

@ -1,5 +1,9 @@
## Unreleased
Improvements:
* Support exec in the server liveness probe [GH-971](https://github.com/hashicorp/vault-helm/pull/971)
## 0.26.1 (October 30, 2023)
Bugs:

View file

@ -179,10 +179,18 @@ spec:
{{- end }}
{{- if .Values.server.livenessProbe.enabled }}
livenessProbe:
{{- if .Values.server.livenessProbe.execCommand }}
exec:
command:
{{- range (.Values.server.livenessProbe.execCommand) }}
- {{ . | quote }}
{{- end }}
{{- else }}
httpGet:
path: {{ .Values.server.livenessProbe.path | quote }}
port: {{ .Values.server.livenessProbe.port }}
scheme: {{ include "vault.scheme" . | upper }}
{{- end }}
failureThreshold: {{ .Values.server.livenessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.server.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.server.livenessProbe.periodSeconds }}

View file

@ -1415,6 +1415,41 @@ load _helpers
[ "${actual}" = "100" ]
}
@test "server/standalone-StatefulSet: liveness exec disabled by default" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe' | tee /dev/stderr)
local actual=$(echo $object |
yq -r '.exec' | tee /dev/stderr)
[ "${actual}" = "null" ]
local actual=$(echo $object |
yq -r '.httpGet' | tee /dev/stderr)
[ ! "${actual}" = "null" ]
}
@test "server/standalone-StatefulSet: liveness exec can be set" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
--set='server.livenessProbe.execCommand={/bin/sh,-c,sleep}' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe' | tee /dev/stderr)
local actual=$(echo $object |
yq -r '.exec.command[0]' | tee /dev/stderr)
[ "${actual}" = "/bin/sh" ]
local actual=$(echo $object |
yq -r '.httpGet' | tee /dev/stderr)
[ "${actual}" = "null" ]
}
#--------------------------------------------------------------------
# args
@test "server/standalone-StatefulSet: add extraArgs" {

View file

@ -818,6 +818,12 @@
"path": {
"type": "string"
},
"port": {
"type": "integer"
},
"execCommand": {
"type": "array"
},
"periodSeconds": {
"type": "integer"
},

View file

@ -531,8 +531,14 @@ server:
# Used to enable a livenessProbe for the pods
livenessProbe:
enabled: false
# Used to define a liveness exec command. If provided, exec is preferred to httpGet (path) as the livenessProbe handler.
execCommand: []
# - /bin/sh
# - -c
# - /vault/userconfig/mylivenessscript/run.sh
# Path for the livenessProbe to use httpGet as the livenessProbe handler
path: "/v1/sys/health?standbyok=true"
# Port number on which livenessProbe will be checked.
# Port number on which livenessProbe will be checked if httpGet is used as the livenessProbe handler
port: 8200
# When a probe fails, Kubernetes will try failureThreshold times before giving up
failureThreshold: 2