So, let's say we assign requiredDuringSchedulingIgnoredDuringExecution
type to node affinity and specify some node selector terms. Let's suppose a pod gets created according to the terms. But, what if a pod gets evicted and it is rescheduled. Would that node affinity/node selector terms which is requiredDuringSchedulingIgnoredDuringExecution
be taken into account when a new pod is created?
requiredDuringSchedulingIgnoredDuringExecution
type of nodeAffinity , unofficially calls "hard rule" guarantee you the pod will be created/RECREATED exactly based on rules you defined.
Example from official kubernetes documentation :
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/e2e-az-name
operator: In
values:
- e2e-az1
- e2e-az2
Above spec will always recreate pod ONLY in nodes with label=kubernetes.io/e2e-az-name
that contains values e2e-az1
or e2e-az2
Scheduling is done by Kubernetes scheduler and every time it will schedule or reschedule a pod it will consider the affinity and antiaffiny defined in pod spec.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.