From a21656594bb42fdb454a467c06ad9b4848ee329f Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 23 Oct 2024 15:19:53 +0300 Subject: [PATCH] nfd-worker: add healthz endpoint --- .../helm/node-feature-discovery/templates/worker.yaml | 6 ++++++ pkg/nfd-worker/nfd-worker.go | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/deployment/helm/node-feature-discovery/templates/worker.yaml b/deployment/helm/node-feature-discovery/templates/worker.yaml index 3c9dcb1e53..526841aabc 100644 --- a/deployment/helm/node-feature-discovery/templates/worker.yaml +++ b/deployment/helm/node-feature-discovery/templates/worker.yaml @@ -47,6 +47,9 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} livenessProbe: + httpGet: + path: /healthz + port: http {{- with .Values.worker.livenessProbe.initialDelaySeconds }} initialDelaySeconds: {{ . }} {{- end }} @@ -60,6 +63,9 @@ spec: timeoutSeconds: {{ . }} {{- end }} readinessProbe: + httpGet: + path: /healthz + port: http {{- with .Values.worker.readinessProbe.initialDelaySeconds }} initialDelaySeconds: {{ . }} {{- end }} diff --git a/pkg/nfd-worker/nfd-worker.go b/pkg/nfd-worker/nfd-worker.go index ec5dff0c3c..00339ef9b6 100644 --- a/pkg/nfd-worker/nfd-worker.go +++ b/pkg/nfd-worker/nfd-worker.go @@ -202,6 +202,10 @@ func newDefaultConfig() *NFDConfig { } } +func (w *nfdWorker) Healthz(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusOK) +} + func (i *infiniteTicker) Reset(d time.Duration) { switch { case d > 0: @@ -308,7 +312,8 @@ func (w *nfdWorker) Run() error { grpcErr := make(chan error) - // Start readiness probe (at this point we're "ready and live") + // Register health probe (at this point we're "ready and live") + httpMux.HandleFunc("/healthz", w.Healthz) // Start HTTP server httpServer := http.Server{Addr: fmt.Sprintf(":%d", w.args.Port), Handler: httpMux}