Skip to content

Commit

Permalink
Merge pull request #249 from mengqiy/whitelist_ns
Browse files Browse the repository at this point in the history
✨ default namespace selector for webhook
  • Loading branch information
k8s-ci-robot authored Dec 14, 2018
2 parents 40894d1 + 7d95fb1 commit b497fd5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/webhook/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b497fd5

Please sign in to comment.