File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,19 @@ func setupChecks(mgr ctrl.Manager) {
100100 }
101101}
102102
103+ // setupWebhookReadinessCheck adds a readiness check that blocks the pod from
104+ // entering "Ready" state (and thus from being added to the Service's endpoints)
105+ // until the webhook server is actually listening. This prevents a race where
106+ // the Kubernetes API server tries to route admission webhook calls to this pod
107+ // before the webhook TLS server is up, which would cause "no endpoints
108+ // available" errors for BareMetalHost operations.
109+ func setupWebhookReadinessCheck (mgr ctrl.Manager ) {
110+ if err := mgr .AddReadyzCheck ("webhook" , mgr .GetWebhookServer ().StartedChecker ()); err != nil {
111+ setupLog .Error (err , "unable to create ready check for webhook server" )
112+ os .Exit (1 )
113+ }
114+ }
115+
103116func setupWebhooks (mgr ctrl.Manager ) {
104117 if err := (& webhooks.BareMetalHost {}).SetupWebhookWithManager (mgr ); err != nil {
105118 setupLog .Error (err , "unable to create webhook" , "webhook" , "BareMetalHost" )
@@ -401,6 +414,7 @@ func main() {
401414 setupChecks (mgr )
402415
403416 if enableWebhook {
417+ setupWebhookReadinessCheck (mgr )
404418 setupWebhooks (mgr )
405419 }
406420
You can’t perform that action at this time.
0 commit comments