diff --git a/pkg/webhook/bootstrap.go b/pkg/webhook/bootstrap.go index f0ac9425e3..b789c05315 100644 --- a/pkg/webhook/bootstrap.go +++ b/pkg/webhook/bootstrap.go @@ -297,6 +297,17 @@ func (s *Server) validatingWHConfigs() (runtime.Object, error) { } func (s *Server) admissionWebhook(path string, wh *admission.Webhook) (*admissionregistration.Webhook, error) { + if wh.NamespaceSelector == nil && len(s.Service.Namespace) > 0 { + wh.NamespaceSelector = &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + { + Key: "control-plane", + Operator: metav1.LabelSelectorOpDoesNotExist, + }, + }, + } + } + webhook := &admissionregistration.Webhook{ Name: wh.GetName(), Rules: wh.Rules,