Adding the /healthz handler to the 404-default-server-with-metris to supprot liveness probing from the k8s masters.
@@ -159,12 +159,21 @@ func (s *server) registerHandlers() {
if *isProd == false {
mux.HandleFunc("/shutdown", s.shutdownHandler())
}
+ mux.HandleFunc("/healthz", s.healthzHandler())
mux.Handle("/metrics", promhttp.Handler())
s.mux = mux
s.httpServer.Handler = mux
}
+// healthz handler handles the liveness probing
+func (s *server) healthzHandler() http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprintf(w, "alive \n")
+ }
+}
+
// shutdown handler handles the graceful shutdown of the server
func (s *server) shutdownHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
