From 551f4e312e957a9228aab78b9843f500b3aaaec1 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Mon, 1 Mar 2021 22:46:05 +0800 Subject: [PATCH] Allow override kubernetes probes (#117) - Allow overriding liveness and readiness probe - Add optional startup probe closes #118 Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/117 Reviewed-by: luhahn Reviewed-by: lafriks Co-authored-by: Michael Kriese Co-committed-by: Michael Kriese --- README.md | 28 +++++++++++++++++++ templates/gitea/statefulset.yaml | 42 ++++++++++++++++++++++------- values.yaml | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c70e8ad..d9b8705 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,34 @@ Annotations can be added to the Gitea pod. |---------------------|-----------------------------------|------------------------------| |gitea.config | Everything in app.ini can be configured with this dict. See Examples for more details | {} | +### Gitea Probes + +Configure Liveness, Readiness and Startup [Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) + +| Parameter | Description | Default | +|---------------------|-----------------------------------|------------------------------| +|gitea.livenessProbe.enabled | Enable liveness probe | true | +|gitea.livenessProbe.initialDelaySeconds | Delay before probe start| 200 | +|gitea.livenessProbe.timeoutSeconds | probe timeout | 1 | +|gitea.livenessProbe.periodSeconds | period between probes | 10 | +|gitea.livenessProbe.successThreshold | Minimum consecutive success probes | 1 | +|gitea.livenessProbe.failureThreshold | Minimum consecutive error probes | 10 | +|gitea.readinessProbe.enabled | Enable readiness probe | true | +|gitea.readinessProbe.initialDelaySeconds | Delay before probe start| 200 | +|gitea.readinessProbe.timeoutSeconds | probe timeout | 1 | +|gitea.readinessProbe.periodSeconds | period between probes | 10 | +|gitea.readinessProbe.successThreshold | Minimum consecutive success probes | 1 | +|gitea.readinessProbe.failureThreshold | Minimum consecutive error probes | 10 | +|gitea.startupProbe.enabled | Enable startup probe | false | +|gitea.startupProbe.initialDelaySeconds | Delay before probe start| 200 | +|gitea.startupProbe.timeoutSeconds | probe timeout | 1 | +|gitea.startupProbe.periodSeconds | period between probes | 10 | +|gitea.startupProbe.successThreshold | Minimum consecutive success probes | 1 | +|gitea.startupProbe.failureThreshold | Minimum consecutive error probes | 10 | +|gitea.customLivenessProbe | Custom liveness probe (needs `gitea.livenessProbe.enabled: false`) | | +|gitea.customReadinessProbe | Custom readiness probe (needs `gitea.readinessProbe.enabled: false`) | | +|gitea.customStartupProbe | Custom startup probe (needs `gitea.startupProbe.enabled: false`) | | + ### Memcached BuiltIn Memcached is loaded as a dependency from [Bitnami](https://github.com/bitnami/charts/tree/master/bitnami/memcached) if enabled in the values. Complete Configuration can be taken from their website. diff --git a/templates/gitea/statefulset.yaml b/templates/gitea/statefulset.yaml index bfaba36..c199ea8 100644 --- a/templates/gitea/statefulset.yaml +++ b/templates/gitea/statefulset.yaml @@ -71,21 +71,45 @@ spec: - name: profiler containerPort: 6060 {{- end }} + {{- if .Values.gitea.livenessProbe.enabled }} livenessProbe: tcpSocket: port: http - initialDelaySeconds: 200 - timeoutSeconds: 1 - periodSeconds: 10 - successThreshold: 1 - failureThreshold: 10 + initialDelaySeconds: {{ .Values.gitea.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.gitea.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.gitea.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.gitea.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.gitea.livenessProbe.failureThreshold }} + {{- else if .Values.gitea.customLivenessProbe }} + livenessProbe: + {{- toYaml .Values.gitea.customLivenessProbe | nindent 12 }} + {{- end }} + {{- if .Values.gitea.readinessProbe.enabled }} readinessProbe: tcpSocket: port: http - initialDelaySeconds: 5 - periodSeconds: 10 - successThreshold: 1 - failureThreshold: 3 + initialDelaySeconds: {{ .Values.gitea.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.gitea.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.gitea.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.gitea.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.gitea.readinessProbe.failureThreshold }} + {{- else if .Values.gitea.customReadinessProbe }} + readinessProbe: + {{- toYaml .Values.gitea.customReadinessProbe | nindent 12 }} + {{- end }} + {{- if .Values.gitea.startupProbe.enabled }} + startupProbe: + tcpSocket: + port: http + initialDelaySeconds: {{ .Values.gitea.startupProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.gitea.startupProbe.periodSeconds }} + timeoutSeconds: {{ .Values.gitea.startupProbe.timeoutSeconds }} + successThreshold: {{ .Values.gitea.startupProbe.successThreshold }} + failureThreshold: {{ .Values.gitea.startupProbe.failureThreshold }} + {{- else if .Values.gitea.customStartupProbe }} + startupProbe: + {{- toYaml .Values.gitea.customStartupProbe | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} securityContext: diff --git a/values.yaml b/values.yaml index 64b3fe4..1475521 100644 --- a/values.yaml +++ b/values.yaml @@ -169,6 +169,52 @@ gitea: builtIn: enabled: true + livenessProbe: + enabled: true + initialDelaySeconds: 200 + timeoutSeconds: 1 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 10 + readinessProbe: + enabled: true + initialDelaySeconds: 5 + timeoutSeconds: 1 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 3 + startupProbe: + enabled: false + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 10 + + # customLivenessProbe: + # httpGet: + # path: /user/login + # port: http + # initialDelaySeconds: 60 + # periodSeconds: 10 + # successThreshold: 1 + # failureThreshold: 10 + # customReadinessProbe: + # httpGet: + # path: /user/login + # port: http + # initialDelaySeconds: 5 + # periodSeconds: 10 + # successThreshold: 1 + # failureThreshold: 3 + # customStartupProbe: + # httpGet: + # path: /user/login + # port: http + # initialDelaySeconds: 60 + # periodSeconds: 10 + # successThreshold: 1 + # failureThreshold: 10 + memcached: service: port: 11211