Skip to content

Commit

Permalink
Setup health endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Oct 23, 2024
1 parent f086821 commit 209b365
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

Expand Down Expand Up @@ -146,6 +147,15 @@ func runManager(metricsAddr, probeAddr, watchNamespace string, enableLeaderElect
os.Exit(1)
}

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}

versionString := "unknown"
if v, ok := debug.ReadBuildInfo(); ok {
versionString = fmt.Sprintf("%s (%s)", v.Main.Version, v.GoVersion)
Expand Down Expand Up @@ -226,6 +236,15 @@ func runMachineAPIControllersManager(metricsAddr, probeAddr, watchNamespace stri
os.Exit(1)
}

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}

if err := (&controllers.MachineAPIControllersReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down

0 comments on commit 209b365

Please sign in to comment.