如何从Kubernetes正常删除节点? [英] How to gracefully remove a node from Kubernetes?

查看:220
本文介绍了如何从Kubernetes正常删除节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按比例放大/缩小机器数量,以增加/减少我的Kubernetes集群中的节点数量.添加一台计算机后,便可以在Kubernetes上成功注册它;因此,将按预期创建一个新节点.但是,我不清楚以后如何平稳地关闭机器.一个好的工作流程是:

I want to scale up/down the number of machines to increase/decrease the number of nodes in my Kubernetes cluster. When I add one machine, I’m able to successfully register it with Kubernetes; therefore, a new node is created as expected. However, it is not clear to me how to smoothly shut down the machine later. A good workflow would be:

  1. 将与要关闭的计算机相关的节点标记为不可调度;
  2. 启动在其他节点中的节点中运行的pod;
  3. 正常删除节点中正在运行的pod;
  4. 删除节点.

如果我理解正确,甚至kubectl drain(讨论)并没有达到我的期望,因为它在删除它们之前没有启动Pod(它依赖复制控制器在之后启动Pod,这可能会导致停机).我想念什么吗?

If I understood correctly, even kubectl drain (discussion) doesn't do what I expect since it doesn’t start the pods before deleting them (it relies on a replication controller to start the pods afterwards which may cause downtime). Am I missing something?

我应该如何正确关闭计算机?

How should I properly shutdown a machine?

推荐答案

列出节点并获取要耗尽或(从群集中删除)的<node-name>

List the nodes and get the <node-name> you want to drain or (remove from cluster)

kubectl get nodes

1)首先排空节点

kubectl drain <node-name>

您可能必须忽略计算机中的守护程序集和本地数据

You might have to ignore daemonsets and local-data in the machine

kubectl drain <node-name> --ignore-daemonsets --delete-local-data

2)编辑节点的实例组(仅在使用kops的情况下)

2) Edit instance group for nodes (Only if you are using kops)

kops edit ig nodes

将MIN和MAX大小设置为-1 只需保存文件(无需执行其他操作)

Set the MIN and MAX size to whatever it is -1 Just save the file (nothing extra to be done)

在耗尽的节点上,您仍然可能会看到一些与守护程序相关的pod,例如网络插件,流利的日志,kubedns/coredns等

You still might see some pods in the drained node that are related to daemonsets like networking plugin, fluentd for logs, kubedns/coredns etc

3)最后删除节点

kubectl delete node <node-name>

4)在s3中提交KOPS的状态:(仅在使用kops的情况下)

4) Commit the state for KOPS in s3: (Only if you are using kops)

kops update cluster --yes

或(如果您使用的是kubeadm)

OR (if you are using kubeadm)

如果您使用的是kubeadm,并且想将计算机重置为运行kubeadm join之前的状态,请运行

If you are using kubeadm and would like to reset the machine to a state which was there before running kubeadm join then run

kubeadm reset

这篇关于如何从Kubernetes正常删除节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆