From bad149be7283b13b4e1c082bc716312e0d58ad30 Mon Sep 17 00:00:00 2001 From: zhoujinyu <2319109590@qq.com> Date: Thu, 29 Jan 2026 10:01:32 +0800 Subject: [PATCH] feat(cron-operator): Add livenessProbe and readinessProbe Signed-off-by: zhoujinyu <2319109590@qq.com> --- .../cron-operator/templates/operator-dp.yaml | 16 ++++ .../charts/cron-operator/values.yaml | 24 ++++++ .../tests/cron-operator/deployment_test.yaml | 86 +++++++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/arena-artifacts/charts/cron-operator/templates/operator-dp.yaml b/arena-artifacts/charts/cron-operator/templates/operator-dp.yaml index e175c1204..22516dd50 100644 --- a/arena-artifacts/charts/cron-operator/templates/operator-dp.yaml +++ b/arena-artifacts/charts/cron-operator/templates/operator-dp.yaml @@ -35,6 +35,22 @@ spec: - containerPort: 8443 name: metrics protocol: TCP + livenessProbe: + httpGet: + path: /metrics + port: metrics + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.livenessProbe.failureThreshold }} + readinessProbe: + httpGet: + path: /metrics + port: metrics + initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} {{- with .Values.resources }} resources: {{- toYaml . | nindent 12 }} diff --git a/arena-artifacts/charts/cron-operator/values.yaml b/arena-artifacts/charts/cron-operator/values.yaml index 26a9ee569..8010271c5 100644 --- a/arena-artifacts/charts/cron-operator/values.yaml +++ b/arena-artifacts/charts/cron-operator/values.yaml @@ -19,3 +19,27 @@ resources: # -- Tolerations for cron-operator pods. tolerations: [] + +# -- Liveness probe configuration. +# The operator pod will be restarted if the liveness probe fails. +livenessProbe: + # -- Number of seconds after the container has started before liveness probes are initiated. + initialDelaySeconds: 15 + # -- How often (in seconds) to perform the probe. + periodSeconds: 30 + # -- Number of seconds after which the probe times out. + timeoutSeconds: 3 + # -- Minimum consecutive failures for the probe to be considered failed. + failureThreshold: 3 + +# -- Readiness probe configuration. +# The operator pod will not receive traffic if the readiness probe fails. +readinessProbe: + # -- Number of seconds after the container has started before readiness probes are initiated. + initialDelaySeconds: 10 + # -- How often (in seconds) to perform the probe. + periodSeconds: 15 + # -- Number of seconds after which the probe times out. + timeoutSeconds: 3 + # -- Minimum consecutive failures for the probe to be considered failed. + failureThreshold: 3 diff --git a/arena-artifacts/tests/cron-operator/deployment_test.yaml b/arena-artifacts/tests/cron-operator/deployment_test.yaml index b649a812c..5f42cb648 100644 --- a/arena-artifacts/tests/cron-operator/deployment_test.yaml +++ b/arena-artifacts/tests/cron-operator/deployment_test.yaml @@ -112,3 +112,89 @@ tests: - key: key4 operator: Exists effect: NoSchedule + +- it: Should have livenessProbe with default values + asserts: + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.path + value: /metrics + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet.port + value: metrics + - equal: + path: spec.template.spec.containers[0].livenessProbe.initialDelaySeconds + value: 15 + - equal: + path: spec.template.spec.containers[0].livenessProbe.periodSeconds + value: 30 + - equal: + path: spec.template.spec.containers[0].livenessProbe.timeoutSeconds + value: 3 + - equal: + path: spec.template.spec.containers[0].livenessProbe.failureThreshold + value: 3 + +- it: Should have readinessProbe with default values + asserts: + - equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet.path + value: /metrics + - equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet.port + value: metrics + - equal: + path: spec.template.spec.containers[0].readinessProbe.initialDelaySeconds + value: 10 + - equal: + path: spec.template.spec.containers[0].readinessProbe.periodSeconds + value: 15 + - equal: + path: spec.template.spec.containers[0].readinessProbe.timeoutSeconds + value: 3 + - equal: + path: spec.template.spec.containers[0].readinessProbe.failureThreshold + value: 3 + +- it: Should allow customizing livenessProbe values + set: + cron: + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 60 + timeoutSeconds: 5 + failureThreshold: 5 + asserts: + - equal: + path: spec.template.spec.containers[0].livenessProbe.initialDelaySeconds + value: 30 + - equal: + path: spec.template.spec.containers[0].livenessProbe.periodSeconds + value: 60 + - equal: + path: spec.template.spec.containers[0].livenessProbe.timeoutSeconds + value: 5 + - equal: + path: spec.template.spec.containers[0].livenessProbe.failureThreshold + value: 5 + +- it: Should allow customizing readinessProbe values + set: + cron: + readinessProbe: + initialDelaySeconds: 20 + periodSeconds: 30 + timeoutSeconds: 5 + failureThreshold: 5 + asserts: + - equal: + path: spec.template.spec.containers[0].readinessProbe.initialDelaySeconds + value: 20 + - equal: + path: spec.template.spec.containers[0].readinessProbe.periodSeconds + value: 30 + - equal: + path: spec.template.spec.containers[0].readinessProbe.timeoutSeconds + value: 5 + - equal: + path: spec.template.spec.containers[0].readinessProbe.failureThreshold + value: 5