|
42 | 42 | watchNamespace string
|
43 | 43 | metricsAddr string
|
44 | 44 | enableLeaderElection bool
|
| 45 | + healthAddr string |
45 | 46 |
|
46 | 47 | scheme = runtime.NewScheme()
|
47 | 48 | setupLog = ctrl.Log.WithName("setup")
|
@@ -72,13 +73,14 @@ func main() {
|
72 | 73 |
|
73 | 74 | syncPeriod := 15 * time.Second
|
74 | 75 | mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
|
75 |
| - Scheme: scheme, |
76 |
| - MetricsBindAddress: metricsAddr, |
77 |
| - Port: 9443, |
78 |
| - LeaderElection: enableLeaderElection, |
79 |
| - LeaderElectionID: "effcf9b8.cluster.x-k8s.io", |
80 |
| - SyncPeriod: &syncPeriod, |
81 |
| - Namespace: watchNamespace, |
| 76 | + Scheme: scheme, |
| 77 | + MetricsBindAddress: metricsAddr, |
| 78 | + Port: 9443, |
| 79 | + LeaderElection: enableLeaderElection, |
| 80 | + LeaderElectionID: "effcf9b8.cluster.x-k8s.io", |
| 81 | + SyncPeriod: &syncPeriod, |
| 82 | + Namespace: watchNamespace, |
| 83 | + HealthProbeBindAddress: healthAddr, |
82 | 84 | })
|
83 | 85 | if err != nil {
|
84 | 86 | setupLog.Error(err, "unable to start manager")
|
@@ -131,6 +133,16 @@ func main() {
|
131 | 133 | }
|
132 | 134 | // +kubebuilder:scaffold:builder
|
133 | 135 |
|
| 136 | + if err := mgr.AddReadyzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil { |
| 137 | + setupLog.Error(err, "unable to create ready check") |
| 138 | + os.Exit(1) |
| 139 | + } |
| 140 | + |
| 141 | + if err := mgr.AddHealthzCheck("webhook", mgr.GetWebhookServer().StartedChecker()); err != nil { |
| 142 | + setupLog.Error(err, "unable to create health check") |
| 143 | + os.Exit(1) |
| 144 | + } |
| 145 | + |
134 | 146 | setupLog.Info("starting manager")
|
135 | 147 | if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
|
136 | 148 | setupLog.Error(err, "problem running manager")
|
@@ -160,4 +172,11 @@ func initFlags(fs *pflag.FlagSet) {
|
160 | 172 | "",
|
161 | 173 | "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.",
|
162 | 174 | )
|
| 175 | + |
| 176 | + fs.StringVar( |
| 177 | + &healthAddr, |
| 178 | + "health-addr", |
| 179 | + ":9440", |
| 180 | + "The address the health endpoint binds to.", |
| 181 | + ) |
163 | 182 | }
|
0 commit comments