Skip to content

Commit 209b365

Browse files
committed
Setup health endpoints
1 parent f086821 commit 209b365

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"k8s.io/utils/ptr"
4141
ctrl "sigs.k8s.io/controller-runtime"
4242
"sigs.k8s.io/controller-runtime/pkg/cache"
43+
"sigs.k8s.io/controller-runtime/pkg/healthz"
4344
"sigs.k8s.io/controller-runtime/pkg/log/zap"
4445
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
4546

@@ -146,6 +147,15 @@ func runManager(metricsAddr, probeAddr, watchNamespace string, enableLeaderElect
146147
os.Exit(1)
147148
}
148149

150+
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
151+
setupLog.Error(err, "unable to set up health check")
152+
os.Exit(1)
153+
}
154+
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
155+
setupLog.Error(err, "unable to set up ready check")
156+
os.Exit(1)
157+
}
158+
149159
versionString := "unknown"
150160
if v, ok := debug.ReadBuildInfo(); ok {
151161
versionString = fmt.Sprintf("%s (%s)", v.Main.Version, v.GoVersion)
@@ -226,6 +236,15 @@ func runMachineAPIControllersManager(metricsAddr, probeAddr, watchNamespace stri
226236
os.Exit(1)
227237
}
228238

239+
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
240+
setupLog.Error(err, "unable to set up health check")
241+
os.Exit(1)
242+
}
243+
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
244+
setupLog.Error(err, "unable to set up ready check")
245+
os.Exit(1)
246+
}
247+
229248
if err := (&controllers.MachineAPIControllersReconciler{
230249
Client: mgr.GetClient(),
231250
Scheme: mgr.GetScheme(),

0 commit comments

Comments
 (0)