diff --git a/deployment/base/worker-daemonset/worker-daemonset.yaml b/deployment/base/worker-daemonset/worker-daemonset.yaml index 614cec440..8bdc062d9 100644 --- a/deployment/base/worker-daemonset/worker-daemonset.yaml +++ b/deployment/base/worker-daemonset/worker-daemonset.yaml @@ -20,9 +20,15 @@ spec: image: gcr.io/k8s-staging-nfd/node-feature-discovery:master imagePullPolicy: Always livenessProbe: + httpGet: + path: /healthz + port: http initialDelaySeconds: 10 periodSeconds: 10 readinessProbe: + httpGet: + path: /healthz + port: http initialDelaySeconds: 5 periodSeconds: 10 failureThreshold: 10 diff --git a/deployment/helm/node-feature-discovery/templates/worker.yaml b/deployment/helm/node-feature-discovery/templates/worker.yaml index 3c9dcb1e5..526841aab 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 cbac62096..6599c85f8 100644 --- a/pkg/nfd-worker/nfd-worker.go +++ b/pkg/nfd-worker/nfd-worker.go @@ -200,6 +200,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: @@ -304,7 +308,8 @@ func (w *nfdWorker) Run() error { return nil } - // 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}