Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

Improvements:

* Support custom exec command in the server readiness probe [GH-1106](https://github.com/hashicorp/vault-helm/pull/1106)

## 0.30.0 (March 27, 2025)

Changes:
Expand Down
4 changes: 4 additions & 0 deletions templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ spec:
# 1 - error
# 2 - sealed
exec:
{{- if .Values.server.readinessProbe.execCommand }}
command: {{- toYaml .Values.server.readinessProbe.execCommand | nindent 14 }}
{{- else }}
command: ["/bin/sh", "-ec", "vault status -tls-skip-verify"]
{{- end }}
{{- end }}
failureThreshold: {{ .Values.server.readinessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.server.readinessProbe.initialDelaySeconds }}
Expand Down
49 changes: 47 additions & 2 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1236,11 +1236,18 @@ load _helpers

@test "server/standalone-StatefulSet: readinessProbe default" {
cd `chart_dir`
local actual=$(helm template \
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.exec.command[2]' | tee /dev/stderr)
yq -r '.spec.template.spec.containers[0].readinessProbe' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.exec.command[2]' | tee /dev/stderr)
[ "${actual}" = "vault status -tls-skip-verify" ]

local actual=$(echo $object |
yq -r '.httpGet' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "server/standalone-StatefulSet: readinessProbe configurable" {
Expand All @@ -1253,6 +1260,44 @@ load _helpers
[ "${actual}" = "null" ]
}

@test "server/standalone-StatefulSet: readiness execCommand configurable" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.execCommand={/bin/sh,-c,sleep}' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.exec.command[2]' | tee /dev/stderr)
[ "${actual}" = "sleep" ]

local actual=$(echo $object |
yq -r '.httpGet' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "server/standalone-StatefulSet: readiness httpGet configurable" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.path=/v1/sys/health?standbyok=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe' | 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" ]

local actual=$(echo $object |
yq -r '.httpGet.path' | tee /dev/stderr)
[ "${actual}" = "/v1/sys/health?standbyok=true" ]
}

@test "server/standalone-StatefulSet: readiness failureThreshold default" {
cd `chart_dir`
local actual=$(helm template \
Expand Down
6 changes: 6 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,18 @@
"enabled": {
"type": "boolean"
},
"execCommand": {
"type": "array"
},
"failureThreshold": {
"type": "integer"
},
"initialDelaySeconds": {
"type": "integer"
},
"path": {
"type": "string"
},
"periodSeconds": {
"type": "integer"
},
Expand Down
12 changes: 9 additions & 3 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,17 @@ server:
# Used to define custom readinessProbe settings
readinessProbe:
enabled: true
# If you need to use a http path instead of the default exec
# Set this, if you want to use a httpGet (path) instead of the default exec as the readinessProbe handler.
# path: /v1/sys/health?standbyok=true

# Port number on which readinessProbe will be checked.
# Port number on which readinessProbe will be checked if httpGet is used as the readinessProbe handler.
port: 8200

# If you need to overwrite default exec command, you can set it here.
# execCommand:
# - "/bin/sh"
# - "-ec"
# - "vault status -tls-skip-verify"

# When a probe fails, Kubernetes will try failureThreshold times before giving up
failureThreshold: 2
# Number of seconds after the container has started before probe initiates
Expand Down