forked from wardviaene/kubernetes-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpod-anti-affinity.yaml
115 lines (115 loc) · 2.49 KB
/
pod-anti-affinity.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
apiVersion: apps/v1
kind: Deployment
metadata:
name: pod-affinity-1
spec:
replicas: 1
selector:
matchLabels:
app: pod-affinity-1
template:
metadata:
labels:
app: pod-affinity-1
spec:
containers:
- name: k8s-demo
image: wardviaene/k8s-demo
ports:
- name: nodejs-port
containerPort: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pod-affinity-2
spec:
replicas: 3
selector:
matchLabels:
app: pod-affinity-2
template:
metadata:
labels:
app: pod-affinity-2
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- pod-affinity-1
topologyKey: "kubernetes.io/hostname"
containers:
- name: redis
image: redis
ports:
- name: redis-port
containerPort: 6379
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pod-affinity-3
spec:
replicas: 3
selector:
matchLabels:
app: pod-affinity-3
template:
metadata:
labels:
app: pod-affinity-3
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- pod-affinity-1
topologyKey: "kubernetes.io/hostname"
containers:
- name: k8s-demo
image: wardviaene/k8s-demo
ports:
- name: nodejs-port
containerPort: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pod-affinity-4
spec:
replicas: 1
selector:
matchLabels:
app: pod-affinity-4
template:
metadata:
labels:
app: pod-affinity-4
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- pod-affinity-1
- pod-affinity-3
topologyKey: "kubernetes.io/hostname"
containers:
- name: k8s-demo
image: wardviaene/k8s-demo
ports:
- name: nodejs-port
containerPort: 3000
---