From 38133af0bc120275797ae1128046daf543955fe8 Mon Sep 17 00:00:00 2001 From: lvlcn-t <75443136+lvlcn-t@users.noreply.github.com> Date: Sun, 28 Jan 2024 17:03:58 +0100 Subject: [PATCH] feat: add health check startup probe --- chart/templates/_helpers.tpl | 18 ++++++++++++++++++ chart/templates/deployment.yaml | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index e6bf3348..a54ab8c1 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -68,3 +68,21 @@ Create the name of the service account to use {{- define "sparrow.sparrowConfigName"}} {{- include "sparrow.fullname" . }}-config {{- end }} + +{{/* +Convert duration to seconds +*/}} +{{- define "sparrow.durationToSeconds" -}} +{{- $duration := . -}} +{{- if hasSuffix "ms" $duration -}} +{{- trimSuffix "ms" $duration | div 1000 | int -}} +{{- else if hasSuffix "s" $duration -}} +{{- trimSuffix "s" $duration | int -}} +{{- else if hasSuffix "m" $duration -}} +{{- trimSuffix "m" $duration | mul 60 | int -}} +{{- else if hasSuffix "h" $duration -}} +{{- trimSuffix "h" $duration | mul 3600 | int -}} +{{- else -}} +{{- $duration | int -}} +{{- end -}} +{{- end -}} diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index a161f716..6fddbfb7 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -75,6 +75,19 @@ spec: volumeMounts: - name: sparrow-config mountPath: /config/ + readinessProbe: + httpGet: + port: http + failureThreshold: 5 + periodSeconds: 5 + {{- if .Values.checksConfig.checks.health }} + startupProbe: + httpGet: + path: /v1/metrics/health + port: http + initialDelaySeconds: {{ include "sparrow.durationToSeconds" .Values.checksConfig.checks.health.interval | default 15 }} + failureThreshold: 10 + {{- end }} volumes: - name: sparrow-config configMap: