Add constraint selector to pod template

PodTopologySpread plugin will only count the existing pod when that
pod's label matches with `constraint.Selector`, which means all pods
could be scheduled to one topology zone when the constraint does not
have any selector defined.

Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
Dave Chen 2020-12-04 18:04:26 +08:00
parent b2ecd1b3a3
commit 58142288a5
2 changed files with 10 additions and 0 deletions

View File

@ -2,11 +2,16 @@ apiVersion: v1
kind: Pod
metadata:
generateName: spreading-pod-
labels:
color: blue
spec:
topologySpreadConstraints:
- maxSkew: 5
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
color: blue
containers:
- image: k8s.gcr.io/pause:3.2
name: pause

View File

@ -2,11 +2,16 @@ apiVersion: v1
kind: Pod
metadata:
generateName: spreading-pod-
labels:
color: blue
spec:
topologySpreadConstraints:
- maxSkew: 5
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
color: blue
containers:
- image: k8s.gcr.io/pause:3.2
name: pause