From a35801f674d49c74653610fe849be470fcb2a5db Mon Sep 17 00:00:00 2001 From: Victor Girardin Date: Wed, 18 Mar 2026 16:19:01 +0100 Subject: [PATCH] implement liveness check --- charts/kminion/templates/daemonset.yaml | 2 +- charts/kminion/templates/deployment.yaml | 10 ++++++++++ charts/kminion/values.yaml | 2 ++ main.go | 1 + minion/service.go | 12 ++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/charts/kminion/templates/daemonset.yaml b/charts/kminion/templates/daemonset.yaml index c820f178..f226bc60 100644 --- a/charts/kminion/templates/daemonset.yaml +++ b/charts/kminion/templates/daemonset.yaml @@ -91,7 +91,7 @@ spec: livenessProbe: failureThreshold: 3 httpGet: - path: /ready + path: /live port: metrics scheme: HTTP initialDelaySeconds: 10 diff --git a/charts/kminion/templates/deployment.yaml b/charts/kminion/templates/deployment.yaml index e99c7021..50bd2e2e 100644 --- a/charts/kminion/templates/deployment.yaml +++ b/charts/kminion/templates/deployment.yaml @@ -94,6 +94,16 @@ spec: {{- end}} resources: {{- toYaml .Values.resources | nindent 12}} + {{- if .Values.deployment.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: /live + port: {{.Values.service.port}} + initialDelaySeconds: 10 + periodSeconds: 10 + failureThreshold: 3 + timeoutSeconds: 1 + {{- end }} {{- if .Values.deployment.readinessProbe.enabled }} readinessProbe: httpGet: diff --git a/charts/kminion/values.yaml b/charts/kminion/values.yaml index a5e210ba..0d2bccdc 100644 --- a/charts/kminion/values.yaml +++ b/charts/kminion/values.yaml @@ -144,6 +144,8 @@ daemonset: enabled: false deployment: + livenessProbe: + enabled: true readinessProbe: enabled: true diff --git a/main.go b/main.go index 2020f439..569f16cb 100644 --- a/main.go +++ b/main.go @@ -109,6 +109,7 @@ func main() { ), ) http.Handle("/ready", minionSvc.HandleIsReady()) + http.Handle("/live", minionSvc.HandleIsLive()) // Start HTTP server address := net.JoinHostPort(cfg.Exporter.Host, strconv.Itoa(cfg.Exporter.Port)) diff --git a/minion/service.go b/minion/service.go index 003bef22..c1bd3f0c 100644 --- a/minion/service.go +++ b/minion/service.go @@ -130,6 +130,18 @@ func (s *Service) HandleIsReady() http.HandlerFunc { } } +func (s *Service) HandleIsLive() http.HandlerFunc { + type response struct { + StatusCode int `json:"statusCode"` + } + return func(w http.ResponseWriter, r *http.Request) { + res := response{StatusCode: http.StatusOK} + resJson, _ := json.Marshal(res) + w.WriteHeader(http.StatusOK) + w.Write(resJson) + } +} + // ensureCompatibility checks whether the options as configured are available in the connected cluster. For example // we will check if the target Kafka's API version support the LogDirs request. If that's not the case we will // disable the option and print a warning message.