Skip to content

Commit b497fd5

Browse files
authored
Merge pull request kubernetes-sigs#249 from mengqiy/whitelist_ns
✨ default namespace selector for webhook
2 parents 40894d1 + 7d95fb1 commit b497fd5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/webhook/bootstrap.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@ func (s *Server) validatingWHConfigs() (runtime.Object, error) {
297297
}
298298

299299
func (s *Server) admissionWebhook(path string, wh *admission.Webhook) (*admissionregistration.Webhook, error) {
300+
if wh.NamespaceSelector == nil && len(s.Service.Namespace) > 0 {
301+
wh.NamespaceSelector = &metav1.LabelSelector{
302+
MatchExpressions: []metav1.LabelSelectorRequirement{
303+
{
304+
Key: "control-plane",
305+
Operator: metav1.LabelSelectorOpDoesNotExist,
306+
},
307+
},
308+
}
309+
}
310+
300311
webhook := &admissionregistration.Webhook{
301312
Name: wh.GetName(),
302313
Rules: wh.Rules,

0 commit comments

Comments
 (0)