|
| 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. Operators that specify a PriorityClass can affect other tenants on a multi-tenant cluster. |
| 12 | +All pods 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. Setting `globalDefault` on a `PriorityClass` means that all pods in 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 | +## Technical Details |
| 26 | + |
| 27 | +`PriorityClass` yaml manifests can be placed in the bundle alongside existing manifests in the `/manifests` directory. The `PriorityClass` manifest will be present |
| 28 | +in the built bundle image and will be placed into the index database when the bundle is added to an index. |
| 29 | + |
| 30 | +`PriorityClass` objects are clusterwide in scope, and will be applied by OLM directly to the cluster. The `PriorityClass` object will have |
| 31 | +a label referencing the operator that it is associated with, and will be manually garbage collected by OLM when the operator is removed. |
| 32 | + |
| 33 | +Prior versions of OLM (pre-0.16.0) will not support creating `PriorityClass` from the bundle. If a `PriorityClass` is present in the bundle, OLM will throw an invalid installplan error |
| 34 | +specifying that the resource is unsupported. |
| 35 | + |
| 36 | +## Limitations on Priority Classes |
| 37 | + |
| 38 | +No limitations are placed on the contents of a `PriorityClass` manifest at this time, but that may change as OLM develops |
| 39 | +an advanced strategy to ensure installed objects do not compromise the cluster. |
| 40 | + |
| 41 | +## Conclusion |
| 42 | + |
| 43 | +`PriorityClasses` are useful but also potentially far-reaching in nature. Be sure to understand the state of your cluster and |
| 44 | +your scheduling requirements before including one in your bundle alongside your operator. Best practice would be to |
| 45 | +include a `PriorityClass` that only affects pods like your operator deployment and the respective operands. Setting the `globalDefault` |
| 46 | +on a `PriorityClass` to true is not advised in the general sense that it affects all pods scheduled in the cluster, whether or not |
| 47 | +they are in the scope of your operator bundle. |
0 commit comments