From 79190dbf2ecd1b3b214561a8a48a14f02459b35f Mon Sep 17 00:00:00 2001 From: Bernard Grymonpon Date: Tue, 14 Jul 2020 16:17:21 +0200 Subject: [PATCH] [stable/mongodb-replicaset] liveness/startupProbe tuning (#23046) * MongoDB liveness/startupProbe tuning Signed-off-by: Bernard Grymonpon * Changes after review - 1.18 as target k8s api version - aligned the values and readme - changed probe for the metrics server Signed-off-by: Bernard Grymonpon --- stable/mongodb-replicaset/Chart.yaml | 2 +- stable/mongodb-replicaset/README.md | 5 +++ .../templates/mongodb-statefulset.yaml | 38 ++++++++++++++++++- stable/mongodb-replicaset/values.yaml | 9 +++++ 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/stable/mongodb-replicaset/Chart.yaml b/stable/mongodb-replicaset/Chart.yaml index d61ac7af8a..634b91003c 100644 --- a/stable/mongodb-replicaset/Chart.yaml +++ b/stable/mongodb-replicaset/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: mongodb-replicaset home: https://github.com/mongodb/mongo -version: 3.16.2 +version: 3.17.0 appVersion: 3.6 description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. diff --git a/stable/mongodb-replicaset/README.md b/stable/mongodb-replicaset/README.md index 4be9a34632..717703cf8e 100644 --- a/stable/mongodb-replicaset/README.md +++ b/stable/mongodb-replicaset/README.md @@ -108,6 +108,11 @@ The following table lists the configurable parameters of the mongodb chart and t | `readinessProbe.periodSeconds` | Readiness probe period seconds | `10` | | `readinessProbe.successThreshold` | Readiness probe success threshold | `1` | | `readinessProbe.timeoutSeconds` | Readiness probe timeout seconds | `1` | +| `startupProbe.failureThreshold` | Startup probe failure threshold | `60` | +| `startupProbe.initialDelaySeconds` | Startup probe initial delay seconds | `5` | +| `startupProbe.periodSeconds` | Startup probe period seconds | `10` | +| `startupProbe.successThreshold` | Startup probe success threshold | `2` | +| `startupProbe.timeoutSeconds` | Startup probe timeout seconds | `5` | | `extraContainers` | Additional containers to add to the StatefulSet | `[]` | | `extraVars` | Set environment variables for the main container | `{}` | | `extraLabels` | Additional labels to add to resources | `{}` | diff --git a/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml b/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml index e65114db93..aaeaf93ed4 100644 --- a/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml +++ b/stable/mongodb-replicaset/templates/mongodb-statefulset.yaml @@ -221,6 +221,24 @@ spec: failureThreshold: {{ .Values.livenessProbe.failureThreshold }} periodSeconds: {{ .Values.livenessProbe.periodSeconds }} successThreshold: {{ .Values.livenessProbe.successThreshold }} +{{- if semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion -}} + startupProbe: + exec: + command: + - mongo + {{- if .Values.tls.enabled }} + - --ssl + - --sslCAFile=/data/configdb/tls.crt + - --sslPEMKeyFile=/work-dir/mongo.pem + {{- end }} + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }} + timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }} + failureThreshold: {{ .Values.startupProbe.failureThreshold }} + periodSeconds: {{ .Values.startupProbe.periodSeconds }} + successThreshold: {{ .Values.startupProbe.successThreshold }} +{{- end }} readinessProbe: exec: command: @@ -296,8 +314,24 @@ spec: /bin/mongodb_exporter --mongodb.uri {{ template "mongodb-replicaset.connection-string" . }} --test - initialDelaySeconds: 30 - periodSeconds: 10 + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} +{{- if semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion -}} + startupProbe: + exec: + command: + - sh + - -c + - >- + /bin/mongodb_exporter + --mongodb.uri {{ template "mongodb-replicaset.connection-string" . }} + --test + initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }} + timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }} + failureThreshold: {{ .Values.startupProbe.failureThreshold }} + periodSeconds: {{ .Values.startupProbe.periodSeconds }} + successThreshold: {{ .Values.startupProbe.successThreshold }} +{{- end }} {{ end }} {{- if .Values.extraContainers }} {{- tpl (toYaml .Values.extraContainers) . | nindent 8 }} diff --git a/stable/mongodb-replicaset/values.yaml b/stable/mongodb-replicaset/values.yaml index 87e267b378..d53c663621 100644 --- a/stable/mongodb-replicaset/values.yaml +++ b/stable/mongodb-replicaset/values.yaml @@ -200,6 +200,15 @@ livenessProbe: periodSeconds: 10 successThreshold: 1 +# Startup probe, will only be added since Kubernetes v1.16 or higher +# When you have a lot of collections/indices, MongoDB need some time to start +startupProbe: + initialDelaySeconds: 5 + timeoutSeconds: 5 + failureThreshold: 60 + periodSeconds: 10 + successThreshold: 2 + # Enables/disables the headless client service clientService: enabled: true