Skip to content

Commit 109c9ae

Browse files
committed
Do not process pods that have their namespaces configured with the annotation
key scheduler.alpha.kubernetes.io/node-selector in nodeenv admission plugin.
1 parent 3f78a4b commit 109c9ae

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/project/apiserver/admission/nodeenv/admission.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ func Register(plugins *admission.Plugins) {
2222
})
2323
}
2424

25+
const (
26+
KubeProjectNodeSelector = "scheduler.alpha.kubernetes.io/node-selector"
27+
)
28+
2529
// podNodeEnvironment is an implementation of admission.MutationInterface.
2630
type podNodeEnvironment struct {
2731
*admission.Handler
@@ -60,6 +64,15 @@ func (p *podNodeEnvironment) admit(a admission.Attributes, mutationAllowed bool)
6064
if err != nil {
6165
return apierrors.NewForbidden(resource, name, err)
6266
}
67+
68+
// If scheduler.alpha.kubernetes.io/node-selector is set on the pod,
69+
// do not process the pod further.
70+
if len(namespace.ObjectMeta.Annotations) > 0 {
71+
if _, ok := namespace.ObjectMeta.Annotations[KubeProjectNodeSelector]; ok {
72+
return nil
73+
}
74+
}
75+
6376
projectNodeSelector, err := p.cache.GetNodeSelectorMap(namespace)
6477
if err != nil {
6578
return err

0 commit comments

Comments
 (0)