coredns: Enforce topologySpreadConstraints

This commit is contained in:
Ciprian Hacman 2025-07-04 14:44:19 +03:00
parent ce3c7b4ec5
commit 6820d751ed
2 changed files with 7 additions and 5 deletions

View File

@ -145,16 +145,18 @@ spec:
{{ ToYAML .KubeDNS.Affinity | indent 8 }} {{ ToYAML .KubeDNS.Affinity | indent 8 }}
{{- end }} {{- end }}
topologySpreadConstraints: topologySpreadConstraints:
{{- if ne GetCloudProvider "metal" }}
# Metal provider doesn't add the "topology.kubernetes.io/zone" label
- maxSkew: 1 - maxSkew: 1
topologyKey: "topology.kubernetes.io/zone" topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: ScheduleAnyway whenUnsatisfiable: DoNotSchedule
labelSelector: labelSelector:
matchLabels: matchLabels:
k8s-app: kube-dns k8s-app: kube-dns
{{- end }}
- maxSkew: 1 - maxSkew: 1
topologyKey: "kubernetes.io/hostname" topologyKey: "kubernetes.io/hostname"
# Normally we use DoNotSchedule here, but because CoreDNS autoscales, we cannot guarantee this constraint can be satisfied whenUnsatisfiable: DoNotSchedule
whenUnsatisfiable: ScheduleAnyway
labelSelector: labelSelector:
matchLabels: matchLabels:
k8s-app: kube-dns k8s-app: kube-dns

View File

@ -5,14 +5,14 @@ topologySpreadConstraints:
app.kubernetes.io/instance: '{{ .Release.Name }}' app.kubernetes.io/instance: '{{ .Release.Name }}'
topologyKey: topology.kubernetes.io/zone topologyKey: topology.kubernetes.io/zone
maxSkew: 1 maxSkew: 1
whenUnsatisfiable: ScheduleAnyway whenUnsatisfiable: DoNotSchedule
- labelSelector: - labelSelector:
matchLabels: matchLabels:
app.kubernetes.io/name: '{{ template "coredns.name" . }}' app.kubernetes.io/name: '{{ template "coredns.name" . }}'
app.kubernetes.io/instance: '{{ .Release.Name }}' app.kubernetes.io/instance: '{{ .Release.Name }}'
topologyKey: kubernetes.io/hostname topologyKey: kubernetes.io/hostname
maxSkew: 1 maxSkew: 1
whenUnsatisfiable: ScheduleAnyway whenUnsatisfiable: DoNotSchedule
autoscaler: autoscaler:
enabled: true enabled: true