[英]How to drain a node using kubernetes python client?
I am trying to automate kubernetes worker nodes using the official kubernetes python-client . 我正在尝试使用官方的kubernetes python-client自动化kubernetes worker节点。 I am currently looking for a way to safely move al the running applications to other nodes . 我目前正在寻找一种方法来安全地将所有正在运行的应用程序移至其他节点 。 We can do so using "kubectl drain". 我们可以使用“ kubectl排水”来做到这一点。 I did not find a way to simulate that functionality using python client. 我没有找到使用python客户端模拟该功能的方法。 I am currently looking into Does this library support drain functionality yet? 我目前正在研究此库是否支持排水功能?
I found the answer. 我找到了答案。 Python client does have support for draining a node but it is not a single command. Python客户端确实支持耗尽节点,但这不是单个命令。 "kubectl drain" operation utilizes Eviction API to safely delete all the workloads running on a node. “ kubectl排出”操作利用Eviction API安全删除节点上运行的所有工作负载。 The python-client has a function create_namespaced_pod_eviction that safely deletes all the pods in a namespace. python客户端具有函数create_namespaced_pod_eviction ,可安全删除命名空间中的所有Pod。 However, "safely" depends on the Pod Disruption Budgets (PDB) that you have defined for the apps running on that node. 但是,“安全”取决于您为该节点上运行的应用程序定义的Pod中断预算(PDB) 。
I am posting this answer hoping that someone might find it useful :) 我正在发布此答案,希望有人会觉得有用:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.