From 6225cfd8b5aa5640151f823aae09d1d65f2556c0 Mon Sep 17 00:00:00 2001 From: Vallery Lancey Date: Tue, 28 May 2019 20:42:48 -0700 Subject: [PATCH] Added explanation of non-preempting PriorityClasses to the "Pod Priority and Preemption" doc. --- .../configuration/pod-priority-preemption.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/content/en/docs/concepts/configuration/pod-priority-preemption.md b/content/en/docs/concepts/configuration/pod-priority-preemption.md index ef5cf9b6c3a18..dc8ec89740f32 100644 --- a/content/en/docs/concepts/configuration/pod-priority-preemption.md +++ b/content/en/docs/concepts/configuration/pod-priority-preemption.md @@ -77,6 +77,12 @@ when a cluster is under resource pressure. For this reason, it is not recommended to disable preemption. {{< /note >}} +{{< note >}} +In Kubernetes 1.15 and later, +PriorityClasses have the option to set `preemptionPolicy: Never`. +This will prevent pods of that PriorityClass from preempting other pods. +{{< /note >}} + In Kubernetes 1.11 and later, preemption is controlled by a kube-scheduler flag `disablePreemption`, which is set to `false` by default. If you want to disable preemption despite the above note, you can set @@ -145,6 +151,47 @@ globalDefault: false description: "This priority class should be used for XYZ service pods only." ``` +### Non-preempting PriorityClasses (alpha) + +1.15 adds the `PreemptionPolicy` field as an alpha feature. +It is disabled by default in 1.15, +and requires the `PreemptionPolicy`[feature gate](https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/ +) to be enabled. + +Pods with `PreemptionPolicy: Never` will be placed in the scheduling queue +ahead of lower-priority pods, +but they cannot preempt other pods. +A non-preempting pod waiting to be scheduled will stay at the head of the +scheduling queue, until sufficient resources are free, +and it can be scheduled. +Non-preempting pods may still be preempted themselves. + +`PreemptionPolicy` defaults to `PreemptLowerPriority`, +which will allow pods of that PriorityClass to preempt lower-priority pods +(as is existing default behavior). +If `PreemptionPolicy` is set to `Never`, +pods in that PriorityClass will be non-preempting. + +An example use case is for data science workloads. +A user may submit a job that they want to be prioritized above other workloads, +but do not wish to discard existing work by preempting running pods. +The high priority job with `PreemptionPolicy: Never` will be scheduled +ahead of other queued pods, +as soon as sufficient cluster resources "naturally" become free. + +#### Example Non-preempting PriorityClass + +```yaml +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: high-priority-nonpreempting +value: 1000000 +preemptionPolicy: Never +globalDefault: false +description: "This priority class will not cause other pods to be preempted." +``` + ## Pod priority After you have one or more PriorityClasses, you can create Pods that specify one