github.com/operator-framework/operator-lifecycle-manager@v0.30.0/doc/design/adding-priority-classes.md (about)

     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  `PriorityClasses` are useful but also potentially far-reaching in nature. Be sure to understand the state of your cluster and
    12  your scheduling requirements before including one in your bundle alongside your operator. Best practice would be to 
    13  include a `PriorityClass` that only affects pods like your operator deployment and the respective operands. 
    14  
    15  `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.
    16  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.
    17  Existing pods running on the cluster are not affected by a new `PriorityClass`, but since clusters are dynamic and pods can be 
    18  rescheduled as nodes cycle in and out, a `PriorityClass` can have an impact on the long term behavior of the cluster. 
    19  
    20  Only one `PriorityClass` object in the cluster is allowed to have the `globalDefault` setting set to true. Attempting to install a `PriorityClass` with `globalDefault` set to true when one
    21  with `globalDefault` already exists on-cluster will result in a Forbidden error from the api-server. Setting `globalDefault` on a `PriorityClass` means that all pods in the cluster
    22  without an explicit priority class will use this default `PriorityClass`. 
    23  
    24  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. 
    25  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. 
    26  
    27  Once a `PriorityClass` is removed, no further pods can be created that reference the deleted `PriorityClass`. 
    28  
    29  ## Technical Details
    30  
    31  `PriorityClass` yaml manifests can be placed in the bundle alongside existing manifests in the `/manifests` directory. The `PriorityClass` manifest will be present
    32  in the bundle image. 
    33  
    34  `PriorityClass` objects are clusterwide in scope, and will be applied by OLM directly to the cluster. The `PriorityClass` object will have
    35  a label referencing the operator that it is associated with. 
    36  
    37  OLM installs additional objects in the bundle after installing the CRDs and the CSV, to ensure proper owner references between the objects
    38  and the CSV. Therefore, there may be an initial period where additional objects are not available to the operator. 
    39  
    40  Prior versions of OLM (pre-0.16.0) do not support `PriorityClass` objects. If a `PriorityClass` is present in a bundle attempting to be installed on-cluster, OLM will throw an invalid installplan error
    41  specifying that the resource is unsupported. 
    42  
    43  ## Limitations on Priority Classes 
    44  
    45  No limitations are placed on the contents of a `PriorityClass` manifest at this time when installing on-cluster, but that may change as OLM develops
    46  an advanced strategy to ensure installed objects do not compromise the cluster. 
    47  
    48  However, the following is a suggested guideline to follow when including `PriorityClass` objects in a bundle. 
    49  * `globalDefault` should always be `false` on a `PriorityClass` included in a bundle.
    50      * Setting `globalDefault` on a `PriorityClass` means that all pods in the cluster without an explicit priority class will use this default `PriorityClass`. 
    51      This can unintentionally affect other pods running in the cluster.