K8s の Pod の Prirority とそれによる Preemption
kubernetesPod の priorityClassName を指定すると対応する PriorityClass の value がその Pod の Priority となる。
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: low-priority
value: -10
globalDefault: false
description: 'pods can be preempted'
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
priorityClassName: low-priority
Pod がスケジューリングされる際にその preemptionPolicy がデフォルトの PreemptLowerPriority のとき、それより低い Priority の Pod を Preempt してリクエストリソースを確保する。また、ノードのリソース不足の際にの Eviction にも Priority が関係する。
Kubernetes のノードのリソース不足による terminationGracePeriodSeconds を待たない evict - sambaiz-net
globalDefault: true な PriorityClass が存在しないときデフォルトで Pod の優先度は 0 になるため正の value を持つ priorityClassName を設定すると DaemonSet を含む大半の Pod が Preempt されてしまうことに注意が必要。
Preempt される Pod は Node ごとに探索される。FailedScheduling イベントに次のような Reason が含まれることがあるが、No preemption victims found for incoming pod はその Node に Priority が低い Pod が存在しないことを表す。
0/10 nodes are available:
8 Insufficient cpu,
1 node(s) had untolerated taint {[node.kubernetes.io/not-ready:](http://node.kubernetes.io/not-ready:) },
1 node(s) didn't match Pod's node affinity/selector.
preemption: 0/10 nodes are available:
1 Insufficient cpu,
8 No preemption victims found for incoming pod,
1 Preemption is not helpful for scheduling..