Add /healthz endpoint to controller-manager
@@ -21,6 +21,7 @@ import (
"errors"
"flag"
"fmt"
+ "net/http"
"os"
"os/signal"
"syscall"
@@ -98,6 +99,9 @@ func Run(opts *options.Options) error {
logs.InitLogs()
defer logs.FlushLogs()
+ // TODO: Make healthz endpoint configurable
+ go serveHealthz(":8080")
+
stopChan := setupSignalHandler()
var err error
@@ -367,3 +371,12 @@ func setupSignalHandler() (stopCh <-chan struct{}) {
return stop
}
+
+func serveHealthz(address string) {
+ http.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
+ w.WriteHeader(http.StatusOK)
+ _, _ = w.Write([]byte("OK"))
+ })
+
+ glog.Fatal(http.ListenAndServe(address, nil))
+}
