mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
kubeadm: only taint CP nodes when the legacy "master" taint is present
During upgrade when a CP node is missing the old / legacy "master" taint, assume the user has manually removed it to allow workloads to schedule. In such cases do not re-taint the node with the new "control-plane" taint.
This commit is contained in:
parent
71df3e819b
commit
b1f3034051
@ -253,16 +253,20 @@ func AddNewControlPlaneTaint(client clientset.Interface) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, n := range nodes.Items {
|
for _, n := range nodes.Items {
|
||||||
// Check if the node has the taint already and skip it if so
|
// Check if the node has the old / new taints
|
||||||
hasTaint := false
|
hasOldTaint := false
|
||||||
|
hasNewTaint := false
|
||||||
for _, t := range n.Spec.Taints {
|
for _, t := range n.Spec.Taints {
|
||||||
if t.String() == kubeadmconstants.ControlPlaneTaint.String() {
|
switch t.String() {
|
||||||
hasTaint = true
|
case kubeadmconstants.OldControlPlaneTaint.String():
|
||||||
break
|
hasOldTaint = true
|
||||||
|
case kubeadmconstants.ControlPlaneTaint.String():
|
||||||
|
hasNewTaint = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the node does not have the taint, patch it
|
// If the old taint is present and the new taint is missing, patch the node with the new taint.
|
||||||
if !hasTaint {
|
// When the old taint is missing, assume the user has manually untainted the node and take no action.
|
||||||
|
if !hasNewTaint && hasOldTaint {
|
||||||
err = apiclient.PatchNode(client, n.Name, func(n *v1.Node) {
|
err = apiclient.PatchNode(client, n.Name, func(n *v1.Node) {
|
||||||
n.Spec.Taints = append(n.Spec.Taints, kubeadmconstants.ControlPlaneTaint)
|
n.Spec.Taints = append(n.Spec.Taints, kubeadmconstants.ControlPlaneTaint)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user