|
| 1 | +# Adding Pod Disruption Budgets |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +OLM supports users including `PodDisruptionBudget` (PDB) objects in their bundle alongside their operator manifests. `PodDisruptionBudgets` |
| 6 | +are used to provide detailed information to the kube-scheduler about how many pods in a collection can be available or unavailable at given time. |
| 7 | +For more info, see the docs at https://kubernetes.io/docs/tasks/run-application/configure-pdb/#protecting-an-application-with-a-poddisruptionbudget. |
| 8 | + |
| 9 | +## Caveats |
| 10 | + |
| 11 | +PDBs are useful for configuring how many operator replicas or operands should run at any given time. However, it's important |
| 12 | +to set reasonable values for any PDBs included in the bundle and carefully consider how the PDB can affect the lifecycle of other resources |
| 13 | +in the cluster, such as nodes, to ensure cluster autoscaling and cluster upgrades are able to proceed if they are enabled. |
| 14 | + |
| 15 | +PDBs are namespaced resources that only affect certain pods selected by the pod selector. However, |
| 16 | +setting `maxUnavailable` to 0 or 0% (or `minAvailable` to 100%) on the PDB means zero voluntary evictions. |
| 17 | +This can make a node impossible to drain and block important lifecycle actions like operator upgrades or even cluster upgrades. |
| 18 | + |
| 19 | +Multiple PDBs can exist in one namespace- this can cause conflicts. For example, a PDB with the same name may already exist in the namespace. |
| 20 | +PDBs should target a unique collection of pods and not overlap with existing pods in the namespace. |
| 21 | +Be sure to know of existing PDBs in the namespace in which your operator and operands will exist in the cluster. |
| 22 | + |
| 23 | +PDBs for pods controlled by operators have additional restrictions around them. See https://kubernetes.io/docs/tasks/run-application/configure-pdb/#arbitrary-controllers-and-selectors |
| 24 | +for additional details - PDBs for operands managed by OLM-installed operators will fall into these restrictions. |
| 25 | + |
| 26 | +## Technical Details |
| 27 | + |
| 28 | +PDB yaml manifests can be placed in the bundle alongside existing manifests in the `/manifests` directory. The PDB manifest will be stored |
| 29 | +in the bundle image. |
| 30 | + |
| 31 | +When OLM attempts to install the bundle, it will see the PDB and create it on-cluster. Since PDBs are namespace-scoped resources, |
| 32 | +it will be created in the same namespace as the `InstallPlan` associated with the operator. The PDB will be visible in the `InstallPlan` |
| 33 | +and if the PDB fails to be installed OLM will provide a descriptive error in the `InstallPlan`. |
| 34 | + |
| 35 | +OLM installs additional objects in the bundle after installing the CRDs and the CSV, to ensure proper owner references between the objects |
| 36 | +and the CSV. Therefore, there may be an initial period where additional objects are not available to the operator. |
| 37 | + |
| 38 | +When the operator is removed, the PDB will be removed as well via the kubernetes garbage collector. The PDB will be updated when installing a newer version of the operator - |
| 39 | +the existing PDB will be updated to the new PDB on-cluster. An upgrade to an operator bundle which does not include a PDB will remove the existing PDB from the cluster. |
| 40 | + |
| 41 | +Prior versions of OLM (pre-0.16.0) do not support PDBs. If a PDB is present in a bundle attempting to be installed on-cluster, OLM will throw an invalid installplan error |
| 42 | +specifying that the resource is unsupported. |
| 43 | + |
| 44 | +## Limitations on Pod Disruption Budgets |
| 45 | + |
| 46 | +No limitations are placed on the contents of a PDB at this time when installing on-cluster, but that may change as OLM develops |
| 47 | +an advanced strategy to ensure installed objects do not compromise the cluster. |
| 48 | + |
| 49 | +However, the following are suggested guidelines to follow when including PDB objects in a bundle. |
| 50 | + |
| 51 | +* `maxUnavailable` field cannot be set to 0 or 0%. |
| 52 | + * This can make a node impossible to drain and block important lifecycle actions like operator upgrades or even cluster upgrades. |
| 53 | +* `minAvailable` field cannot be set to 100%. |
| 54 | + * This can make a node impossible to drain and block important lifecycle actions like operator upgrades or even cluster upgrades. |
0 commit comments