Using Pod Disruption Budgets (PDB) in SAAP#
Pod Disruption Budget (PDB) is a crucial tool for maintaining the availability and stability of your applications in SAAP during updates and disruptions. By setting the minimum and maximum pod availability, you can ensure that your application remains operational even in the face of cluster changes.
In this tutorial, you will learn how to use Pod Disruption Budget (PDB) to manage the availability and stability of your applications in SAAP during updates and maintenance activities. PDB help ensure that a minimum number of pods are available and operational at all times, reducing the risk of service disruptions.
Objectives#
- Enable replicas.
- Configure a Pod Disruption Budget for an application deployed on SAAP.
- Observe the behavior of the PDB by deleting a pod and analyzing the changes in PDB status.
Key Results#
- Successfully enable and monitor a Pod Disruption Budget for the application's deployment on SAAP.
Tutorial#
Let's scale up the number of replicas
to see how pdb
works.
-
Add
replicas: 3
indeploy/values.yaml
.It should look like this
Make sure autoscaling is
enabled: false
, or you can scale up theminReplicas
to match the replicas, that way you don't need to disable autoscaling.Note
The indentation should be application.deployment.replicas.
-
Enable
pdb
in yourdeploy/values.yaml
file. Add the following YAML:# Enable Pod Disruption Budget (PDB) for your application's pods. pdb: # Set PDB enabled to true to activate the Pod Disruption Budget. enabled: true # Specify the minimum number of available pods during disruptions. In this case, ensure at least 1 pod is available at all times. minAvailable: 2 # Specify the maximum number of pods that can be unavailable simultaneously during disruptions maxUnavailable: 2
It should look like this:
Look at the different colors that indicates indentation.
Note
The indentation should be application.pdb.
-
Save and run
tilt up
at the root of your directory. Hit the space bar and the browser withTILT
logs will be shown. If everything is green then the changes will be deployed on the cluster.Let's see the number of replicas.
-
Log in to SAAP. In your namespace check if the
replicaSet
has created the number ofreplicaCounts
which is3
. -
To check if
pdb
is created, switch to your namespace, go to Administrator > Home > Search and search forpdb
. -
Click on
PodDisruptionBudget
and see the newly createdpdb
namedreview
. -
Click on
review
pdb
. Go toYAML
, scroll down and see thestatus
ofpdb
. Check out the status andcurrentHealthy: 3
,desiredHealthy: 2
which satisfies the condition ofminAvailable: 2
. We can see theDisruptionAllowed
status istrue
. -
let's scale down the replicas to create a disruption and see if
pdb
works accurately.As soon as the replicas are scaled down, the
pdb
condition will enforcereplicaSet
to make sure the minimum replicas are available. -
Delete the
review
pod and check thepdb status
. -
Go to
pdb review
, and check thestatus
now. Click on reload. Now look at thecurrentHealthy: 1
, which clearly shows thatpdb
is working fine.As soon as the pods are recreated,
pdb status
will change tocurrentHealthy: 3
which meets the condition perfectly. Click onreload
and you will see the updated status.
Remember that the behavior of the PDB
and the speed at which it restores pod availability may be influenced by factors such as node resources, cluster conditions, and pod scheduling rules. It's important to give the system some time to react and observe how it gradually restores the desired number of healthy pods according to the PDB
constraints.
Awesome! Let's move on to the next tutorial to add a network policy to your application.