Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes - ReplicaSet vs PodDisruptionBudget

I was wondering what added value gives the PodDisruptionBudget.

As far as I understand, PodDisruptionBudget promises that a certain amount of nodes will always remain in the cluster while there are 2 options to decide how: minAvailable / maxUnavailable.

Now, when I define ReplicaSet I define how many replicas I want. So if for example I define 2, there won't be less than 2 replicas. Then what gives the PodDisruptionBudget?

like image 934
jrz Avatar asked Oct 12 '25 00:10

jrz


1 Answers

PodDisruptionBudget helps in ensuring zero downtime for an application which ReplicaSet can't guarantee.

The following post explains with an example how PodDisruptionBudget can be useful in achieving zero downtime for an application:

Quoting the post, the node upgrade is a normal scenario as described in:

Let’s consider a scenario, we need to upgrade version of node or update the spec often. Cluster downscaling is also a normal condition. In these cases, the pods running on the to-be-deleted nodes needs to be drained.

kubectl drain is performed on one of the nodes for the upgrade:

We need to remove node1 from the pool which we cannot do it by detaching instantly as that will lead to termination of all the pods running in there which can get services down. First step before detaching node is to make the node unscheduled.

Running kubectl get pods -w will show the pods running on the node get in termination state which leads to a downtime:

If you quickly check the pods with kubectl get pods , it will terminate all the running pods instantly which were scheduled on node1 . This could lead a downtime! If you are running few number of pods and all of them are scheduled on same node, it will take some time for the pods to be scheduled on other node.

PodDisruptionBudget with minAvailable are useful in such scenarios to achieve zero downtime. Replicaset will only ensure that the replicas number of pods will be created on other nodes during the process.

If you just have a Replicaset with one replica and no PodDisruptionBudget specified, the pod will be terminated and a new pod will be created on other nodes. This is where PDBs provide the added advantage over the Replicaset.

For the PodDisruptionBudget to work, there must be at least 2 pods running for a label selector otherwise, the node cannot be drained gracefully and it will be evicted forcefully when grace time ends.

like image 71
Krishna Chaurasia Avatar answered Oct 14 '25 21:10

Krishna Chaurasia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!