What are Pod Disruption Budgets (PDB) in Kubernetes?

Introduction

Do you know what are Pod Disruption Budgets (PDB) in Kubernetes and how it provides the high availability to your applications?

Before understanding PDB, Let’s first understand a little about disruptions in Kubernetes 👇

What are Disruptions?

👉 In general, Disruption means disturbance or problems which interrupt an event, activity, or process. In case of Kubernetes, pods are containing our applications and any interruption to them will cause a disruption to our application.
👉 There can be 2 types of disruptions to an application:
☑ Voluntary Disruptions
☑ Involuntary Disruptions

1️⃣ Voluntary Disruptions

👉 Any disruption to the application caused by application owner or cluster administrator intentionally are categorized as Voluntary Disruptions.
👉 Few examples are:
☑ Deleting the deployment or other controller that manages the pod
☑ Updating a deployment’s pod template causing a restart
☑ Draining a node for repair or upgrade or scale down
☑ Removing a pod from a node to permit something else to fit on that node.

2️⃣ Involuntary Disruptions

👉 Any unavoidable cases such as hardware or system error are considered as Involuntary Disruptions.
👉 Few examples are:
☑ A hardware failure of the physical machine backing the node
☑ A Kernel panic
☑ Cloud provider or hypervisor failure makes VM disappear

Now, since we understand the disruptions and its types, let’s understand what are PDBs.

What is Pod Disruption Budget?

👉 Kubernetes offers this feature for running highly available applications even with voluntary disruptions.
👉 A PDB limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions.
👉 A PDB specifies the number of replicas that an application can tolerate having, relative to how many it is intended to have. 
👉 For example, a Deployment which has a .spec.replicas: 5 is supposed to have 5 pods at any given time. If its PDB allows for there to be 4 at a time, then the Eviction API will allow voluntary disruption of one (but not two) pods at a time.
👉 Involuntary disruptions cannot be prevented by PDBs; however they do count against the budget.
👉 Pods which are deleted or unavailable due to a rolling upgrade to an application do count against the disruption budget, but workload resources (such as Deployment and StatefulSet) are not limited by PDBs when doing rolling upgrades.

References

🔗 Kubernetes Official documentation for understanding PDB concepts
🔗 Practice task to configure PDB

"Knowledge Sharing Is Powerful"
Scroll to Top