File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ const (
1313 labelAlphaNodeRoleExcludeBalancer = "alpha.service-controller.kubernetes.io/exclude-balancer"
1414 labelEKSComputeType = "eks.amazonaws.com/compute-type"
1515
16- toBeDeletedByCATaint = "ToBeDeletedByClusterAutoscaler"
16+ toBeDeletedByCATaint = "ToBeDeletedByClusterAutoscaler"
17+ toBeDeletedByKarpenterTaint = "karpenter.sh/disrupted"
1718)
1819
1920var (
@@ -61,12 +62,17 @@ func GetTrafficProxyNodeSelector(tgb *elbv2api.TargetGroupBinding) (labels.Selec
6162// IsNodeSuitableAsTrafficProxy check whether node is suitable as a traffic proxy.
6263// This should be checked in additional to the nodeSelector defined in TargetGroupBinding.
6364func IsNodeSuitableAsTrafficProxy (node * corev1.Node ) bool {
64- // ToBeDeletedByClusterAutoscaler taint is added by cluster autoscaler before removing node from cluster
65- // Marking the node as unsuitable for traffic once the taint is observed on the node
6665 for _ , taint := range node .Spec .Taints {
66+ // ToBeDeletedByClusterAutoscaler taint is added by cluster autoscaler before removing node from cluster
67+ // Marking the node as unsuitable for traffic once the taint is observed on the node
6768 if taint .Key == toBeDeletedByCATaint {
6869 return false
6970 }
71+ // karpenter.sh/disrupted:NoSchedule taint is added by karpenter before removing node from cluster
72+ // Marking the node as unsuitable for traffic once the taint is observed on the node
73+ if taint .Key == toBeDeletedByKarpenterTaint && taint .Effect == corev1 .TaintEffectNoSchedule {
74+ return false
75+ }
7076 }
7177
7278 return true
Original file line number Diff line number Diff line change @@ -131,6 +131,31 @@ func TestIsNodeSuitableAsTrafficProxy(t *testing.T) {
131131 },
132132 want : false ,
133133 },
134+ {
135+ name : "node is ready but tainted with karpenter.sh/disrupted" ,
136+ args : args {
137+ node : & corev1.Node {
138+ Status : corev1.NodeStatus {
139+ Conditions : []corev1.NodeCondition {
140+ {
141+ Type : corev1 .NodeReady ,
142+ Status : corev1 .ConditionTrue ,
143+ },
144+ },
145+ },
146+ Spec : corev1.NodeSpec {
147+ Unschedulable : false ,
148+ Taints : []corev1.Taint {
149+ {
150+ Key : toBeDeletedByKarpenterTaint ,
151+ Effect : corev1 .TaintEffectNoSchedule ,
152+ },
153+ },
154+ },
155+ },
156+ },
157+ want : false ,
158+ },
134159 }
135160 for _ , tt := range tests {
136161 t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments