Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/backend/endpoint_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const (
labelAlphaNodeRoleExcludeBalancer = "alpha.service-controller.kubernetes.io/exclude-balancer"
labelEKSComputeType = "eks.amazonaws.com/compute-type"

toBeDeletedByCATaint = "ToBeDeletedByClusterAutoscaler"
toBeDeletedByCATaint = "ToBeDeletedByClusterAutoscaler"
toBeDeletedByKarpenterTaint = "karpenter.sh/disrupted"
)

var (
Expand Down Expand Up @@ -61,12 +62,17 @@ func GetTrafficProxyNodeSelector(tgb *elbv2api.TargetGroupBinding) (labels.Selec
// IsNodeSuitableAsTrafficProxy check whether node is suitable as a traffic proxy.
// This should be checked in additional to the nodeSelector defined in TargetGroupBinding.
func IsNodeSuitableAsTrafficProxy(node *corev1.Node) bool {
// ToBeDeletedByClusterAutoscaler taint is added by cluster autoscaler before removing node from cluster
// Marking the node as unsuitable for traffic once the taint is observed on the node
for _, taint := range node.Spec.Taints {
// ToBeDeletedByClusterAutoscaler taint is added by cluster autoscaler before removing node from cluster
// Marking the node as unsuitable for traffic once the taint is observed on the node
if taint.Key == toBeDeletedByCATaint {
return false
}
// karpenter.sh/disrupted:NoSchedule taint is added by karpenter before removing node from cluster
// Marking the node as unsuitable for traffic once the taint is observed on the node
if taint.Key == toBeDeletedByKarpenterTaint && taint.Effect == corev1.TaintEffectNoSchedule {
return false
}
}

return true
Expand Down
25 changes: 25 additions & 0 deletions pkg/backend/endpoint_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,31 @@ func TestIsNodeSuitableAsTrafficProxy(t *testing.T) {
},
want: false,
},
{
name: "node is ready but tainted with karpenter.sh/disrupted",
args: args{
node: &corev1.Node{
Status: corev1.NodeStatus{
Conditions: []corev1.NodeCondition{
{
Type: corev1.NodeReady,
Status: corev1.ConditionTrue,
},
},
},
Spec: corev1.NodeSpec{
Unschedulable: false,
Taints: []corev1.Taint{
{
Key: toBeDeletedByKarpenterTaint,
Effect: corev1.TaintEffectNoSchedule,
},
},
},
},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading