// Module included in the following assemblies:
//
// * post_installation_configuration/day_2_core_cnf_clusters/updating/update-rhacm-talm-worker-batching.adoc

:_mod-docs-content-type: PROCEDURE
[id="core-cluster-upgrade-worker-batching-pdb_{context}"]
= Configuring worker node batching by using pod disruption budgets

[role="_abstract"]
You can configure `PodDisruptionBudget` resources to control how your workloads tolerate node draining during cluster updates.
Pod disruption budgets ensure that a minimum number of pod replicas remain available during worker node updates.

.Prerequisites

* You have access to the target cluster with cluster-admin privileges.
* The `oc` CLI tool is installed and configured.
* You have identified critical workloads that run with replicas.

.Procedure

. Create a `PodDisruptionBudget` resource for each critical workload:
+
[source,yaml]
----
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: <pdb_name>
  namespace: <namespace>
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      app: <app_label>
----
+
where:
+
--
* `<pdb_name>`: Specifies a name for the `PodDisruptionBudget` resource, for example `cnf-workload-pdb`.
* `<namespace>`: Specifies the namespace where the workload runs, for example `cnf-workload`.
* `maxUnavailable`: Specifies the maximum number of pods that can be unavailable during a disruption. Set this value to at least `1` to allow node draining to proceed.
* `<app_label>`: Specifies the label selector that matches the pods for this workload.
--

. Apply the `PodDisruptionBudget` resource by running the following command:
+
[source,terminal]
----
$ oc apply -f <pdb_filename>.yaml
----

. Verify that the pod disruption budget allows at least one disruption by running the following command:
+
[source,terminal]
----
$ oc get pdb <pdb_name> -n <namespace>
----
+
The following example shows the output:
+
[source,terminal]
----
NAME               MIN AVAILABLE   MAX UNAVAILABLE   ALLOWED DISRUPTIONS   AGE
cnf-workload-pdb   N/A             1                 1                     30s
----
+
[IMPORTANT]
====
Ensure the `ALLOWED DISRUPTIONS` column shows a value greater than 0. If this value is 0, the pod disruption budget blocks node draining and updates stall. Do not set `minAvailable` to 100% of replicas, as this prevents any disruption.
====

. Repeat steps 1-3 for all critical workloads in your cluster.

. Verify all pod disruption budgets across the cluster by running the following command:
+
[source,terminal]
----
$ oc get pdb -A
----

.Verification

* Verify that no pod disruption budgets are blocking disruptions by running the following command:
+
[source,terminal]
----
$ oc get pdb -A -o jsonpath='{range .items[?(@.status.disruptionsAllowed==0)]}{.metadata.namespace}{"\t"}{.metadata.name}{"\n"}{end}'
----
+
This command must produce no output. If the output lists any pod disruption budgets, adjust their configuration before updating.
