Protect critical workloads with a PDB
A pod disruption budget (PDB) is an essential feature for maintaining the high availability of applications in a cluster. The PDB specifies a target size, which is the minimum availability for a particular type of pod. This means that a minimum number of replicas of a particular pod type must be running at any given time. If the number of running replicas falls below the target size, Kubernetes prevents further disruptions to the remaining replicas until the target size is met. PDBs help to ensure that workloads are not affected by these events and can continue to run uninterrupted. When a disruption occurs, Kubernetes attempts to gracefully evict pods from the affected nodes while maintaining the number of replicas specified in the PDB.
You can use a PDB to declare the minAvailable
and maxUnavailable
number of replicas. For example, if you want at least three copies of your app to be
available, create a PDB that is similar to the following example:
apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: my-svc-pdb spec: minAvailable: 3 selector: matchLabels: app: my-svc
Setting up PDBs correctly for your applications helps to minimize the disruption during planned or unplanned events. You can use the anti-affinity rule to schedule a deployment's pods on different nodes and avoid PDB delays during node upgrades.