1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

nfd-worker: add healthz endpoint

This commit is contained in:
Markus Lehtonen 2024-10-23 15:19:53 +03:00
parent d831fcbdf9
commit 4ba35eb8ce
3 changed files with 18 additions and 1 deletions

View file

@ -20,9 +20,15 @@ spec:
image: gcr.io/k8s-staging-nfd/node-feature-discovery:master image: gcr.io/k8s-staging-nfd/node-feature-discovery:master
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe: livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 10 initialDelaySeconds: 10
periodSeconds: 10 periodSeconds: 10
readinessProbe: readinessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 10 periodSeconds: 10
failureThreshold: 10 failureThreshold: 10

View file

@ -47,6 +47,9 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
livenessProbe: livenessProbe:
httpGet:
path: /healthz
port: http
{{- with .Values.worker.livenessProbe.initialDelaySeconds }} {{- with .Values.worker.livenessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ . }} initialDelaySeconds: {{ . }}
{{- end }} {{- end }}
@ -60,6 +63,9 @@ spec:
timeoutSeconds: {{ . }} timeoutSeconds: {{ . }}
{{- end }} {{- end }}
readinessProbe: readinessProbe:
httpGet:
path: /healthz
port: http
{{- with .Values.worker.readinessProbe.initialDelaySeconds }} {{- with .Values.worker.readinessProbe.initialDelaySeconds }}
initialDelaySeconds: {{ . }} initialDelaySeconds: {{ . }}
{{- end }} {{- end }}

View file

@ -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) { func (i *infiniteTicker) Reset(d time.Duration) {
switch { switch {
case d > 0: case d > 0:
@ -304,7 +308,8 @@ func (w *nfdWorker) Run() error {
return nil 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 // Start HTTP server
httpServer := http.Server{Addr: fmt.Sprintf(":%d", w.args.Port), Handler: httpMux} httpServer := http.Server{Addr: fmt.Sprintf(":%d", w.args.Port), Handler: httpMux}