Scheduling
Anti-Affinity
Required Anti-Affinity
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld
labels:
app: helloworld
spec:
replicas: 1
selector:
matchLabels:
app: helloworld
template:
metadata:
labels:
app: helloworld
spec:
containers:
- name: helloworld
image: gcr.io/.../helloworld
# Add configuration for anti-affinity
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- helloworld
# Prefer spreading the Pods across multiple Nodes.
# There are other keys you can use, e.g., anti-affinity
# across zones.
topologyKey: "kubernetes.io/hostname"Preferred Anti-Affinity
Affinity
Disruption Budget
Last updated
Was this helpful?