abdidarmawan007 / k8s-PodDisruptionBudget

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is "PodDisruptionBudget"?

"PodDisruptionBudget" is a Kubernetes object which limits the number pods of a replicated application that are down simultaneously from voluntary disruptions.

Why "PodDisruptionBudget" is needed to be configured?

If "PodDisruptionBudget" is not configured

Let's say, your microservice is running on a Kubernetes cluster with "PodDisruptionBudget" and configured 2 replicas like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: your-microservice
  namespace: your-namespace
spec:
  replicas: 2
...

The cluster has 3 nodes and your microservice's pods "app-1" and "app-2" are running on "node-1" and "node-2":

1

Now a cluster administrator (Microservices Platform member) is going to drain node-1 in order to upgrade the cluster:

2

"app-1" is now terminating and a new pod "app-3" is pending state. At this point, if the cluster administrator tries to drain "node-2":

3

What happened? Yes, you don't have any healthy pods now.

PodDisruptionBudget protects your microservices from this situation.

If "PodDisruptionBudget" is configured

Now you have same microservice with "PodDisruptionBudget" like this:

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: your-microservice
  namespace: your-namespace
spec:
  minAvailable: 30%
  selector:
  matchLabels:
      app: your-microservice
# ...

Even if the cluster administrator tries to drain "node-2", it will block because there is only 1 available pod.

4

That's why "PodDisruptionBudget" is needed to be configured for your microservices.

What's next

About