I am trying to automate kubernetes worker nodes using the official kubernetes python-client. I am currently looking for a way to safely move al the running applications to other nodes . We can do so using "kubectl drain". I did not find a way to simulate that functionality using python client. I am currently looking into Does this library support drain functionality yet?
How to drain a node using kubernetes python client?
Asked Answered
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 :)
Note that there's currently (July 2019) a method to delete a node in the python-client. –
Iphigenia
© 2022 - 2024 — McMap. All rights reserved.