Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit a9afbfb

Browse files
committed
templates: ensure critical components dont coexist
This commit adds antiaffinity rules to the controller manager and the sheduler to ensure that these deployments' pods do not all end up on the same master node, especially now that they are pinned with node selectors. To make this possible on small clusters, e.g. those with 1 master node, this is specified with "preferred" rather than "required".
1 parent 6ed1ce9 commit a9afbfb

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pkg/asset/internal/templates.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,22 @@ spec:
323323
tier: control-plane
324324
component: kube-controller-manager
325325
spec:
326+
affinity:
327+
podAntiAffinity:
328+
preferredDuringSchedulingIgnoredDuringExecution:
329+
- weight: 100
330+
podAffinityTerm:
331+
labelSelector:
332+
matchExpressions:
333+
- key: tier
334+
operator: In
335+
values:
336+
- control-plane
337+
- key: component
338+
operator: In
339+
values:
340+
- kube-contoller-manager
341+
topologyKey: kubernetes.io/hostname
326342
nodeSelector:
327343
master: "true"
328344
containers:
@@ -388,6 +404,22 @@ spec:
388404
tier: control-plane
389405
component: kube-scheduler
390406
spec:
407+
affinity:
408+
podAntiAffinity:
409+
preferredDuringSchedulingIgnoredDuringExecution:
410+
- weight: 100
411+
podAffinityTerm:
412+
labelSelector:
413+
matchExpressions:
414+
- key: tier
415+
operator: In
416+
values:
417+
- control-plane
418+
- key: component
419+
operator: In
420+
values:
421+
- kube-scheduler
422+
topologyKey: kubernetes.io/hostname
391423
nodeSelector:
392424
master: "true"
393425
containers:

0 commit comments

Comments
 (0)