@@ -24,6 +24,7 @@ import (
2424
2525 "github.com/operator-framework/operator-lib/leader"
2626 "sigs.k8s.io/controller-runtime/pkg/cache"
27+ "sigs.k8s.io/controller-runtime/pkg/healthz"
2728 "sigs.k8s.io/controller-runtime/pkg/manager"
2829 "sigs.k8s.io/controller-runtime/pkg/manager/signals"
2930 metricsServer "sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -44,6 +45,11 @@ func RunOperator(cmd *cobra.Command, args []string) {
4445 util .InitLogger (logrus .DebugLevel )
4546 }
4647 version .RunVersion (cmd , args )
48+ // Probe address from CLI flag (defaults to :8081)
49+ probeAddr := os .Getenv ("HEALTH_PROBE_BIND_ADDRESS" )
50+ if probeAddr == "" {
51+ probeAddr = ":8081"
52+ }
4753
4854 config := util .KubeConfig ()
4955
@@ -66,6 +72,7 @@ func RunOperator(cmd *cobra.Command, args []string) {
6672 Metrics : metricsServer.Options {
6773 BindAddress : fmt .Sprintf ("%s:%d" , metricsHost , metricsPort ),
6874 },
75+ HealthProbeBindAddress : probeAddr , // Serve /healthz and /readyz here
6976 })
7077 if err != nil {
7178 log .Fatalf ("Failed to create manager: %s" , err )
@@ -97,6 +104,11 @@ func RunOperator(cmd *cobra.Command, args []string) {
97104 log .Fatalf ("Failed AddToClusterScopedManager: %s" , err )
98105 }
99106
107+ // Register readiness endpoint on mgr
108+ if err := mgr .AddReadyzCheck ("readyz" , healthz .Ping ); err != nil {
109+ log .Fatalf ("Failed to add readiness check: %s" , err )
110+ }
111+
100112 util .Panic (mgr .Add (manager .RunnableFunc (func (ctx context.Context ) error {
101113 system .RunOperatorCreate (cmd , args )
102114 return nil
0 commit comments