简体   繁体   English

如何使用kubernetes python客户端耗尽节点?

[英]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.

相关问题 如何在EKS中优雅地排空节点? - How to gracefully drain a node in EKS? 如何使用 nodeport Kubernetes 连接到主节点 - How to connect to the master node using nodeport Kubernetes 相当于 kubectl get pods 的 Python Kubernetes 客户端 - Python Kubernetes Client equivalent of kubectl get pods 从 Kube.netes Python 客户端登录一个 GitLab repo - Login to a GitLab repo from Kubernetes Python client 使用 Kubernetes Python 客户端加载 kubect 配置文件返回错误:无效的 kube-config 文件 - Load kubect config file using Kubernetes Python client returns error: Invalid kube-config file 使用 Kubernetes、Python 和 Apache-Spark 3.2.0 在客户端模式下运行 spark 的两个单独图像? - Two separate images to run spark in client-mode using Kubernetes, Python with Apache-Spark 3.2.0? 当 python 代码在 kube.netes pod 中运行时,如何获取客户端 IP 地址? - How to get client IP address when the python code is running inside a kubernetes pod? 使用Docker运行多节点kubernetes - Running multi-node kubernetes using docker Kubernetes - 使用 kubeadm 加入节点失败 - Kubernetes - Join node failure using kubeadm CoreOS Kubernetes如何监视Node进程? - CoreOS Kubernetes how to monitor Node processes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM