mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Remove nodes with Cluster Autoscaler taint from LB backends.
This commit is contained in:
parent
fa6bb7cad0
commit
62799e33ee
@ -55,6 +55,9 @@ const (
|
|||||||
// should be changed appropriately.
|
// should be changed appropriately.
|
||||||
minRetryDelay = 5 * time.Second
|
minRetryDelay = 5 * time.Second
|
||||||
maxRetryDelay = 300 * time.Second
|
maxRetryDelay = 300 * time.Second
|
||||||
|
// ToBeDeletedTaint is a taint used by the CLuster Autoscaler before marking a node for deletion. Defined in
|
||||||
|
// https://github.com/kubernetes/autoscaler/blob/e80ab518340f88f364fe3ef063f8303755125971/cluster-autoscaler/utils/deletetaint/delete.go#L36
|
||||||
|
ToBeDeletedTaint = "ToBeDeletedByClusterAutoscaler"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cachedService struct {
|
type cachedService struct {
|
||||||
@ -671,6 +674,14 @@ func (s *Controller) getNodeConditionPredicate() NodeConditionPredicate {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove nodes that are about to be deleted by the cluster autoscaler.
|
||||||
|
for _, taint := range node.Spec.Taints {
|
||||||
|
if taint.Key == ToBeDeletedTaint {
|
||||||
|
klog.V(4).Infof("Ignoring node %v with autoscaler taint %+v", node.Name, taint)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we have no info, don't accept
|
// If we have no info, don't accept
|
||||||
if len(node.Status.Conditions) == 0 {
|
if len(node.Status.Conditions) == 0 {
|
||||||
return false
|
return false
|
||||||
|
@ -1580,6 +1580,9 @@ func Test_getNodeConditionPredicate(t *testing.T) {
|
|||||||
|
|
||||||
{want: true, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{}}}},
|
{want: true, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{}}}},
|
||||||
{want: false, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{v1.LabelNodeExcludeBalancers: ""}}}},
|
{want: false, input: &v1.Node{Status: validNodeStatus, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{v1.LabelNodeExcludeBalancers: ""}}}},
|
||||||
|
|
||||||
|
{want: false, input: &v1.Node{Status: v1.NodeStatus{Conditions: []v1.NodeCondition{{Type: v1.NodeReady, Status: v1.ConditionTrue}}},
|
||||||
|
Spec: v1.NodeSpec{Taints: []v1.Taint{{Key: ToBeDeletedTaint, Value: fmt.Sprint(time.Now().Unix()), Effect: v1.TaintEffectNoSchedule}}}}},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user