What is the primary purpose of a Pod Disruption Budget (PDB) in Kubernetes?
Think about how Kubernetes manages pod availability during maintenance or upgrades.
A Pod Disruption Budget ensures that voluntary disruptions like node drains or upgrades do not reduce the number of available pods below a certain threshold.
Given this Pod Disruption Budget YAML:
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: myapp-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: myappAssuming 3 pods labeled app=myapp are running, what will be the status of the PDB after draining a node hosting 2 pods?
Consider how many pods remain healthy after removing 2 pods from 3 total.
With 3 pods and minAvailable 2, draining 2 pods leaves only 1 healthy pod, which is below the minimum. So disruptions allowed is 0.
Which YAML snippet correctly defines a Pod Disruption Budget that allows at most 1 pod to be unavailable at any time for pods labeled app=web?
Check the correct field name and value type for limiting unavailable pods.
maxUnavailable: 1 correctly limits disruptions to 1 pod. Option A uses minAvailable which is different. Option A uses invalid string value. Option A allows 2 pods unavailable, not 1.
You created a Pod Disruption Budget with minAvailable: 3 for pods labeled app=api. There are 5 pods running. However, when you drain a node hosting 3 pods, Kubernetes allows eviction and the pods terminate. Why?
Check if the PDB selector matches the pods exactly.
If the selector does not match pods, the PDB does not apply, so evictions proceed without blocking.
Arrange the steps in the correct order to safely upgrade Kubernetes nodes without violating Pod Disruption Budgets for a deployment with 4 replicas and minAvailable: 3.
Think about preventing new pods, safely evicting existing pods, upgrading, then reopening the node.
First cordon to stop new pods, then drain to evict pods respecting PDB, upgrade node, then uncordon to allow pods again.