Skip to content

Commit 850c544

Browse files
committed
nfd-worker: add healthz endpoint
1 parent 4959a13 commit 850c544

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

deployment/base/worker-daemonset/worker-daemonset.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ spec:
2020
image: gcr.io/k8s-staging-nfd/node-feature-discovery:master
2121
imagePullPolicy: Always
2222
livenessProbe:
23+
httpGet:
24+
path: /healthz
25+
port: http
2326
initialDelaySeconds: 10
2427
periodSeconds: 10
2528
readinessProbe:
29+
httpGet:
30+
path: /healthz
31+
port: http
2632
initialDelaySeconds: 5
2733
periodSeconds: 10
2834
failureThreshold: 10

deployment/helm/node-feature-discovery/templates/worker.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ spec:
4747
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
4848
imagePullPolicy: {{ .Values.image.pullPolicy }}
4949
livenessProbe:
50+
httpGet:
51+
path: /healthz
52+
port: http
5053
{{- with .Values.worker.livenessProbe.initialDelaySeconds }}
5154
initialDelaySeconds: {{ . }}
5255
{{- end }}
@@ -60,6 +63,9 @@ spec:
6063
timeoutSeconds: {{ . }}
6164
{{- end }}
6265
readinessProbe:
66+
httpGet:
67+
path: /healthz
68+
port: http
6369
{{- with .Values.worker.readinessProbe.initialDelaySeconds }}
6470
initialDelaySeconds: {{ . }}
6571
{{- end }}

pkg/nfd-worker/nfd-worker.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ func newDefaultConfig() *NFDConfig {
203203
}
204204
}
205205

206+
func (w *nfdWorker) Healthz(writer http.ResponseWriter, _ *http.Request) {
207+
writer.WriteHeader(http.StatusOK)
208+
}
209+
206210
func (i *infiniteTicker) Reset(d time.Duration) {
207211
switch {
208212
case d > 0:
@@ -316,7 +320,8 @@ func (w *nfdWorker) Run() error {
316320
return nil
317321
}
318322

319-
// Start readiness probe (at this point we're "ready and live")
323+
// Register health endpoint (at this point we're "ready and live")
324+
httpMux.HandleFunc("/healthz", w.Healthz)
320325

321326
// Start HTTP server
322327
httpServer := http.Server{Addr: fmt.Sprintf(":%d", w.args.Port), Handler: httpMux}

0 commit comments

Comments
 (0)