Skip to content

Commit 2d6a62f

Browse files
committed
helm: add a health check and liveness probe
1 parent 8d559ad commit 2d6a62f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

deploy/charts/venafi-kubernetes-agent/templates/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ spec:
9494
- containerPort: 8081
9595
name: http-metrics
9696
{{- end }}
97+
livenessProbe:
98+
httpGet:
99+
path: /healthz
100+
port: 8081
101+
initialDelaySeconds: 15
102+
periodSeconds: 20
103+
readinessProbe:
104+
httpGet:
105+
path: /readyz
106+
port: 8081
107+
initialDelaySeconds: 5
108+
periodSeconds: 10
97109
{{- with .Values.nodeSelector }}
98110
nodeSelector:
99111
{{- toYaml . | nindent 8 }}

pkg/agent/run.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ func Run(cmd *cobra.Command, args []string) {
8080
go func() {
8181
prometheus.MustRegister(metricPayloadSize)
8282
metricsServer := http.NewServeMux()
83+
84+
// Health check endpoint. Since we haven't figured a good way of knowning
85+
// what "ready" means for the agent, we just return 200 OK inconditionally.
86+
// The goal is to satisfy some Kubernetes distributions, like OpenShift,
87+
// that require a liveness and health probe to be present for each pod.
88+
metricsServer.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
89+
w.WriteHeader(http.StatusOK)
90+
})
91+
metricsServer.HandleFunc("/readyz", func(w http.ResponseWriter, r *http.Request) {
92+
w.WriteHeader(http.StatusOK)
93+
})
94+
8395
metricsServer.Handle("/metrics", promhttp.Handler())
8496
err := http.ListenAndServe(":8081", metricsServer)
8597
if err != nil && !errors.Is(err, http.ErrServerClosed) {

0 commit comments

Comments
 (0)