Skip to content

Instantly share code, notes, and snippets.

@sebdoido
Created September 12, 2022 13:19
Show Gist options
  • Save sebdoido/16c2d65a7ad5d988736e3b48267a1e1d to your computer and use it in GitHub Desktop.
Save sebdoido/16c2d65a7ad5d988736e3b48267a1e1d to your computer and use it in GitHub Desktop.
bbc-topologySpreadConstraints
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-test
namespace: kube-system
spec:
strategy:
rollingUpdate:
maxSurge: 1
selector:
matchLabels:
app: nginx-test
replicas: 2
template:
metadata:
labels:
app: nginx-test
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: ScheduleAnyway # toleration zone issue
labelSelector:
matchLabels:
app: nginx-test
- maxSkew: 2
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule # clusterAutoscaler will start a new node if needed
labelSelector:
matchLabels:
app: nginx-test
tolerations:
- effect: NoSchedule
key: cloud.blabla.io/k8s-volatile
operator: Equal
value: "true"
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 10
podAffinityTerm:
labelSelector:
matchLabels:
app: nginx-test
topologyKey: kubernetes.io/hostname
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: cloud.blabla.io/k8s-volatile
operator: Exists
containers:
- name: nginx
image: nginx:1.14.2
resources:
requests:
cpu: 500m
ports:
- containerPort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment