Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

feat: add anti affinity to coredns deployment #249

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions parts/k8s/addons/coredns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ spec:
annotations:
seccomp.security.alpha.kubernetes.io/pod: docker/default
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to summarize what this is expressing. Is it:

"Don't schedule coredns pods onto a node that already has a kube-dns-labeled pod in the same availability zone."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, except it will only try, if it can't it will schedule both pods on the same node if no other is available.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thanks. Hence the preferredDuringSchedulingIgnoredDuringExecution instead of requiredDuringSchedulingIgnoredDuringExecution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly

labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- kube-dns
topologyKey: failure-domain.beta.kubernetes.io/zone
weight: 10
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- kube-dns
topologyKey: kubernetes.io/hostname
weight: 5
serviceAccountName: coredns
tolerations:
- key: node-role.kubernetes.io/master
Expand Down