Modified: for 12.1.2
The SBC CNe uses PodDisruptionBudget
for all deployments and statefulsets to ensure that the SBC service is not disrupted when the worker node is drained. A Pod Disruption Budget (PDB) limits the number of Pods of a replicated application that are down simultaneously from voluntary disruptions. Kubernetes workloads might become disrupted due to node maintenance or failures. When nodes are taken down for maintenance or experience failures, the pods running on them are terminated and rescheduled on other nodes. This can lead to decreased availability and potential data loss or downtime.
Examples of unavoidable hardware/software failures that might lead to pod disruption:
Examples of disruptions voluntarily triggered by the application or cluster owner:
Pod Disruption Budgets allow a minimum number of Pods to remain alive for highly available applications so the service is not disrupted. For example, if we have four pods (replicas) for an application and need at least two for the service to perform normally, we can specify a PDB with a minimum available count of two. When any voluntary disruption occurs, Kubernetes deletes only two pods at once and deletes the other two after two new pods spawn in some other worker node and become ready. This ensures that at least two pods always remain available during the disruption.
# PodDisruptionBudget implementation for all pod types apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ .Release.Name }}-<pod_type>-pdb namespace: {{ .Values.global.namespace }} spec: maxUnavailable: 1 selector: matchLabels: app: {{ .Release.Name }}-<pod_type>
maxUnavailable
is set to 1 for all PDBs. Kubernetes will try to delete one pod at a time so that the number of available Pods is always greater than replica_count - 1
.
This ensures that the number of active pods remains equal to the expected count. If any active pod is deleted, one standby pod will take its place. Thus, the number of standby pods is always "0" or one less than the expected count.
Not all voluntary disruptions respect PodDisruptionBudgets, such as a deployment or pod that is deleted with the "kubectl delete" command
Commands that respect PodDisruptionBudgets:
Eviction API: (eviction-api-reference) Creates an Eviction object, which causes the API server to terminate the Pod.
curl -v -H 'Content-type: application/json' http://localhost:8090/api/v1/namespaces/<namespace_name>/pods/<pod_name>/eviction -d "{\"apiVersion\": \"policy/v1\",\"kind\": \"Eviction\",\"metadata\": {\"name\": \"<pod_name>\",\"namespace\": \"<namespace_name>\"}}"