Skip to content

Commit

Permalink
LivenessProbe support - you can use it, doesn't mean you should
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Sep 18, 2021
1 parent d9fa868 commit f38708f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
10 changes: 10 additions & 0 deletions charts/onechart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.path }}
port: {{ .Values.containerPort }}
scheme: HTTP
{{- with .Values.livenessProbe.settings }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- include "common.volumeMountsRef.tpl" . | nindent 10 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down
45 changes: 45 additions & 0 deletions charts/onechart/tests/deployment_liveness_probe_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
suite: test deployment
templates:
- deployment.yaml
- configmap.yaml
tests:
- it: Should set a liveness probe
set:
livenessProbe:
enabled: true
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: "/"
port: 80
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
failureThreshold: 3
- it: Should not set a livenessProbe
asserts:
- isNull:
path: spec.template.spec.containers[0].livenessProbe
- it: Should tune liveness probe
set:
livenessProbe:
enabled: true
settings:
periodSeconds: 30
asserts:
- equal:
path: spec.template.spec.containers[0].livenessProbe
value:
httpGet:
path: "/"
port: 80
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 3
failureThreshold: 3
11 changes: 11 additions & 0 deletions charts/onechart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ probe:
timeoutSeconds: 3
failureThreshold: 3

# Before you use a liveness probe: https://srcco.de/posts/kubernetes-liveness-probes-are-dangerous.html
livenessProbe:
enabled: false
path: "/"
settings:
initialDelaySeconds: 0
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
failureThreshold: 3

secretEnabled: false

shell: "/bin/sh"
Expand Down

0 comments on commit f38708f

Please sign in to comment.