12.1.3 Handling disruptions
View in the book.
Buy the book.
kubectl create -f Chapter12/12.1_PDB/pdb.yaml
To try, cordon and drain every node to simulate an upgrade
for node in $(kubectl get nodes -o jsonpath='{.items[*].metadata.name}'); do
kubectl cordon $node
kubectl drain $node --ignore-daemonsets --delete-emptydir-data
done
Then, watch the Pods
$ watch -d kubectl get pods
NAME READY STATUS RESTARTS AGE
timeserver-f94cc5dd9-5wgnm 0/1 ContainerCreating 0 25s
timeserver-f94cc5dd9-gjc7n 1/1 Running 0 116s
timeserver-f94cc5dd9-jg47t 1/1 Terminating 0 8m45s
timeserver-f94cc5dd9-kskkw 1/1 Running 0 8m45s
Since we specified maxUnavailable: 1
there should always be 2 out of the
3 replicas in the Running
state. Note that this isn’t a hard guarantee
and events can disrupt this count temporarily.