Skip to content

Commit

Permalink
nfd-worker: add healthz endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
marquiz committed Nov 4, 2024
1 parent bdb9b8a commit a216565
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions deployment/helm/node-feature-discovery/templates/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -60,6 +63,9 @@ spec:
timeoutSeconds: {{ . }}
{{- end }}
readinessProbe:
httpGet:
path: /healthz
port: http
{{- with .Values.worker.readinessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ . }}
{{- end }}
Expand Down
7 changes: 6 additions & 1 deletion pkg/nfd-worker/nfd-worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit a216565

Please sign in to comment.