|
| 1 | +# Adding Priority Classes |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +OLM supports users including `PriorityClass` objects in their bundle alongside their operator manifests. `PriorityClass` |
| 6 | +is used to establish a priority, or weight, to a collection of pods in order to aid the kube-scheduler when assigning pods |
| 7 | +to nodes. For more info, see the docs at https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass. |
| 8 | + |
| 9 | +## Caveats |
| 10 | + |
| 11 | +`PriorityClass` objects are clusterwide in scope, meaning they can affect the scheduling of pods in all namespaces. All pods |
| 12 | +have a default priority of zero, and only those pods explicitly selected by the `PriorityClass` object will be given a priority when created. |
| 13 | +Existing pods running on the cluster are not affected by a new `PriorityClass`, but since clusters are dynamic and pods can be |
| 14 | +rescheduled as nodes cycle in and out, a `PriorityClass` can have an impact on the long term behavior of the cluster. |
| 15 | + |
| 16 | +Exactly one `PriorityClass` object is allowed to have the `globalDefault` setting set to true - this means that all pods on the cluster |
| 17 | +without an explicit priority class will use this default `PriorityClass`. Make sure you understand the effects of setting a global |
| 18 | +priority for pods running in the cluster before setting a `PriorityClass` as the `globalDefault`. |
| 19 | + |
| 20 | +Pods with higher priorities can preempt pods with lower priorities when they are being scheduled onto nodes: preemption can result in lower-priority pods being evicted to make room for the higher priority pod. |
| 21 | +If the `PriorityClass` of the pod is extremely high (higher than the priority of core components) scheduling the pod can potentially disrupt core components running in the cluster. |
| 22 | + |
| 23 | +Once a `PriorityClass` is removed, no further pods can be created that reference the deleted `PriorityClass`. |
| 24 | + |
| 25 | +## Conclusion |
| 26 | + |
| 27 | +`PriorityClasses` are useful but also potentially far-reaching in nature. Be sure to understand the state of your cluster and |
| 28 | +your scheduling requirements before including one in your bundle alongside your operator. Best practice would be to |
| 29 | +include a `PriorityClass` that only affects pods like your operator deployment and the respective operands. Setting the `globalDefault` |
| 30 | +on a `PriorityClass` to true is not advised in the general sense that it affects all pods scheduled in the cluster, whether or not |
| 31 | +they are in the scope of your operator bundle. |
0 commit comments