kubernetes-hands-on/13-affinity-anti-affinity/01-pod-anti-affinity.yml

43 lines
956 B
YAML

---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod-anti-affinity1
labels:
run: nginx-pod-anti-affinity
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: run
operator: In
values:
- nginx-pod-anti-affinity
topologyKey: kubernetes.io/hostname
containers:
- name: nginx
image: nginx
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod-anti-affinity2
labels:
run: nginx-pod-anti-affinity
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: run
operator: In
values:
- nginx-pod-anti-affinity
topologyKey: kubernetes.io/hostname
containers:
- name: nginx
image: nginx