Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable probe values #387

Merged
merged 6 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
17 changes: 9 additions & 8 deletions templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,23 @@ spec:
exec:
command: ["/bin/sh", "-ec", "vault status -tls-skip-verify"]
{{- end }}
failureThreshold: 2
initialDelaySeconds: 5
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 5
failureThreshold: {{ .Values.server.readinessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.server.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.server.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.server.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.server.readinessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.server.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.server.livenessProbe.path | quote }}
port: 8200
scheme: {{ include "vault.scheme" . | upper }}
failureThreshold: {{ .Values.server.livenessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.server.livenessProbe.initialDelaySeconds }}
periodSeconds: 3
successThreshold: 1
timeoutSeconds: 5
periodSeconds: {{ .Values.server.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.server.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.server.livenessProbe.timeoutSeconds }}
{{- end }}
lifecycle:
# Vault container doesn't receive SIGTERM from Kubernetes
Expand Down
198 changes: 194 additions & 4 deletions test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,110 @@ load _helpers
[ "${actual}" = "null" ]
}

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

@test "server/standalone-StatefulSet: readiness failureThreshold configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
--set 'server.readinessProbe.failureThreshold=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.failureThreshold' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: readiness initialDelaySeconds default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.initialDelaySeconds' | tee /dev/stderr)
[ "${actual}" = "5" ]
}

@test "server/standalone-StatefulSet: readiness initialDelaySeconds configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
--set 'server.readinessProbe.initialDelaySeconds=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.initialDelaySeconds' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: readiness periodSeconds default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.periodSeconds' | tee /dev/stderr)
[ "${actual}" = "3" ]
}

@test "server/standalone-StatefulSet: readiness periodSeconds configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
--set 'server.readinessProbe.periodSeconds=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.periodSeconds' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: readiness successThreshold default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.successThreshold' | tee /dev/stderr)
[ "${actual}" = "1" ]
}

@test "server/standalone-StatefulSet: readiness successThreshold configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
--set 'server.readinessProbe.successThreshold=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.successThreshold' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: readiness timeoutSeconds default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.timeoutSeconds' | tee /dev/stderr)
[ "${actual}" = "5" ]
}

@test "server/standalone-StatefulSet: readiness timeoutSeconds configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.readinessProbe.enabled=true' \
--set 'server.readinessProbe.timeoutSeconds=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].readinessProbe.timeoutSeconds' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: livenessProbe default" {
cd `chart_dir`
Expand All @@ -982,7 +1086,28 @@ load _helpers
[ "${actual}" = "/v1/sys/health?standbyok=true" ]
}

@test "server/standalone-StatefulSet: livenessProbe initialDelaySeconds default" {
@test "server/standalone-StatefulSet: liveness failureThreshold default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.failureThreshold' | tee /dev/stderr)
[ "${actual}" = "2" ]
}

@test "server/standalone-StatefulSet: liveness failureThreshold configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
--set 'server.livenessProbe.failureThreshold=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.failureThreshold' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: liveness initialDelaySeconds default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
Expand All @@ -992,17 +1117,82 @@ load _helpers
[ "${actual}" = "60" ]
}

@test "server/standalone-StatefulSet: livenessProbe initialDelaySeconds configurable" {
@test "server/standalone-StatefulSet: liveness initialDelaySeconds configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
--set 'server.livenessProbe.initialDelaySeconds=30' \
--set 'server.livenessProbe.initialDelaySeconds=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.initialDelaySeconds' | tee /dev/stderr)
[ "${actual}" = "30" ]
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: liveness periodSeconds default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.periodSeconds' | tee /dev/stderr)
[ "${actual}" = "3" ]
}

@test "server/standalone-StatefulSet: liveness periodSeconds configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
--set 'server.livenessProbe.periodSeconds=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.periodSeconds' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: liveness successThreshold default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.successThreshold' | tee /dev/stderr)
[ "${actual}" = "1" ]
}

@test "server/standalone-StatefulSet: liveness successThreshold configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
--set 'server.livenessProbe.successThreshold=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.successThreshold' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

@test "server/standalone-StatefulSet: liveness timeoutSeconds default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.timeoutSeconds' | tee /dev/stderr)
[ "${actual}" = "5" ]
}

@test "server/standalone-StatefulSet: liveness timeoutSeconds configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.livenessProbe.enabled=true' \
--set 'server.livenessProbe.timeoutSeconds=100' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].livenessProbe.timeoutSeconds' | tee /dev/stderr)
[ "${actual}" = "100" ]
}

#--------------------------------------------------------------------
# args
@test "server/standalone-StatefulSet: add extraArgs" {
cd `chart_dir`
local actual=$(helm template \
Expand Down
20 changes: 20 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,31 @@ server:
enabled: true
# If you need to use a http path instead of the default exec
# path: /v1/sys/health?standbyok=true

# 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
initialDelaySeconds: 5
# How often (in seconds) to perform the probe
periodSeconds: 3
# Minimum consecutive successes for the probe to be considered successful after having failed
successThreshold: 1
# Number of seconds after which the probe times out.
timeoutSeconds: 5
tvoran marked this conversation as resolved.
Show resolved Hide resolved
# Used to enable a livenessProbe for the pods
livenessProbe:
enabled: false
path: "/v1/sys/health?standbyok=true"
# 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
initialDelaySeconds: 60
# How often (in seconds) to perform the probe
periodSeconds: 3
# Minimum consecutive successes for the probe to be considered successful after having failed
successThreshold: 1
# Number of seconds after which the probe times out.
timeoutSeconds: 5

# Used to set the sleep time during the preStop step
preStopSleepSeconds: 5
Expand Down