Skip to content

Commit

Permalink
do not put multiple identical tolerations on the CoreDNS deployment (#…
Browse files Browse the repository at this point in the history
…3299)

Co-authored-by: Christoph Mewes <christoph@kubermatic.com>
  • Loading branch information
kubermatic-bot and xrstf authored Jul 8, 2024
1 parent f84808d commit a32adf9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/tasks/coredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package tasks

import (
"context"
"slices"

"k8c.io/kubeone/pkg/fail"
"k8c.io/kubeone/pkg/state"
Expand Down Expand Up @@ -47,13 +48,19 @@ func patchCoreDNS(s *state.State) error {
return fail.KubeClient(err, "getting %T %s", dep, key)
}

dep.Spec.Template.Spec.Tolerations = append(dep.Spec.Template.Spec.Tolerations,
corev1.Toleration{
Key: "node.cloudprovider.kubernetes.io/uninitialized",
Value: "true",
Effect: corev1.TaintEffectNoSchedule,
},
)
toleration := corev1.Toleration{
Key: "node.cloudprovider.kubernetes.io/uninitialized",
Value: "true",
Effect: corev1.TaintEffectNoSchedule,
}

// older KubeOne releases accidentally put multiple identical tolerations
// on the Deployment; clean them all up
dep.Spec.Template.Spec.Tolerations = slices.DeleteFunc(dep.Spec.Template.Spec.Tolerations, func(t corev1.Toleration) bool {
return t.Key == toleration.Key
})

dep.Spec.Template.Spec.Tolerations = append(dep.Spec.Template.Spec.Tolerations, toleration)

if s.Cluster.Features.CoreDNS.Replicas != nil {
dep.Spec.Replicas = s.Cluster.Features.CoreDNS.Replicas
Expand Down

0 comments on commit a32adf9

Please sign in to comment.