diff --git a/pkg/server/api/api.go b/pkg/server/api/api.go index 9d80dd374..9f348545e 100644 --- a/pkg/server/api/api.go +++ b/pkg/server/api/api.go @@ -30,6 +30,9 @@ const ( // MultusDelegateAPIEndpoint is an endpoint for multus delegate request (for hotplug) MultusDelegateAPIEndpoint = "/delegate" defaultMultusRunDir = "/run/multus/" + + // MultusHealthAPIEndpoint is an endpoint API clients can query to know if they can communicate w/ multus server + MultusHealthAPIEndpoint = "/healthz" ) // DoCNI sends a CNI request to the CNI server via JSON + HTTP over a root-owned unix socket, diff --git a/pkg/server/server.go b/pkg/server/server.go index 6c5f27ac2..e8e62d67c 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -215,6 +215,12 @@ func newCNIServer(rundir string, kubeClient *k8s.ClientInfo, exec invoke.Exec, s } }))).Methods("POST") + router.HandleFunc(api.MultusHealthAPIEndpoint, promhttp.InstrumentHandlerCounter(s.metrics.requestCounter.MustCurryWith(prometheus.Labels{"handler": api.MultusHealthAPIEndpoint}), + http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Header().Set("Content-Type", "application/json") + }))).Methods("GET") + return s, nil }