-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopology-spread-constraints-donotschedule.yaml
62 lines (62 loc) · 2.02 KB
/
topology-spread-constraints-donotschedule.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# helper pod that "blocks" a node
apiVersion: v1
kind: Pod
metadata:
name: topology-spread-constraints-donotschedule-demo-helper
labels:
app: topology-spread-constraints-donotschedule-demo
app.kubernetes.io/component: node-blocker
spec:
priorityClassName: system-cluster-critical # ensure this pod is scheduled
containers:
- image: nginx
name: nginx
ports:
- name: http
containerPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: topology-spread-constraints-donotschedule-demo
name: topology-spread-constraints-donotschedule-demo
spec:
replicas: 10
selector:
matchLabels:
app: topology-spread-constraints-donotschedule-demo
app.kubernetes.io/component: spread-constraints-demo
template:
metadata:
labels:
app.kubernetes.io/component: spread-constraints-demo
app: topology-spread-constraints-donotschedule-demo
spec:
containers:
- image: nginx
name: nginx
ports:
- name: http
containerPort: 80
topologySpreadConstraints:
- labelSelector:
matchLabels:
app: topology-spread-constraints-donotschedule-demo
app.kubernetes.io/component: spread-constraints-demo
topologyKey: kubernetes.io/hostname
maxSkew: 1
whenUnsatisfiable: DoNotSchedule
# This affinity only shows what happens when one node is "blocked"
# i.e. the anti-affinity requires us to schedule to a node where the
# helper pod is not deployed to but our topologySpreadConstraints require
# us to not have a difference of more than one pods per node.
# The same behavior would apply if one node is full (resource-wise)
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: topology-spread-constraints-donotschedule-demo
app.kubernetes.io/component: node-blocker
topologyKey: kubernetes.io/hostname