How to drain a node using kubernetes python client?

Viewed 2498
1 Answers

I found the answer. Python client does have support for draining a node but it is not a single command. "kubectl drain" operation utilizes Eviction API to safely delete all the workloads running on a node. The python-client has a function create_namespaced_pod_eviction that safely deletes all the pods in a namespace. However, "safely" depends on the Pod Disruption Budgets (PDB) that you have defined for the apps running on that node.

I am posting this answer hoping that someone might find it useful :)

Related