File tree 2 files changed +34
-3
lines changed
2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ const (
13
13
labelAlphaNodeRoleExcludeBalancer = "alpha.service-controller.kubernetes.io/exclude-balancer"
14
14
labelEKSComputeType = "eks.amazonaws.com/compute-type"
15
15
16
- toBeDeletedByCATaint = "ToBeDeletedByClusterAutoscaler"
16
+ toBeDeletedByCATaint = "ToBeDeletedByClusterAutoscaler"
17
+ toBeDeletedByKarpenterTaint = "karpenter.sh/disrupted"
17
18
)
18
19
19
20
var (
@@ -61,12 +62,17 @@ func GetTrafficProxyNodeSelector(tgb *elbv2api.TargetGroupBinding) (labels.Selec
61
62
// IsNodeSuitableAsTrafficProxy check whether node is suitable as a traffic proxy.
62
63
// This should be checked in additional to the nodeSelector defined in TargetGroupBinding.
63
64
func 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
66
65
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
67
68
if taint .Key == toBeDeletedByCATaint {
68
69
return false
69
70
}
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
+ }
70
76
}
71
77
72
78
return true
Original file line number Diff line number Diff line change @@ -131,6 +131,31 @@ func TestIsNodeSuitableAsTrafficProxy(t *testing.T) {
131
131
},
132
132
want : false ,
133
133
},
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
+ },
134
159
}
135
160
for _ , tt := range tests {
136
161
t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments