简体   繁体   English

将 Kubernetes statefulset pod 移动到另一个节点

[英]Move Kubernetes statefulset pod to another node

My k8s cluster initially have 2node and 1master and I deployed statefulset with 3pods, so 3pods with PVC are running on 2 nodes.我的 k8s 集群最初有 2node 和 1master,我用 3pods 部署了 statefulset,所以带有 PVC 的 3pods 在 2 个节点上运行。 Now I increased nodes from 2 to 3. So now k8s is 3nodes and 1master.现在我将节点从 2 个增加到 3 个。所以现在 k8s 是 3nodes 和 1master。 I would like to move one of the statefulset pod to newly added node without deleting PVC so that 3 pods will spread on 3nodes each.我想将一个 statefulset pod 移动到新添加的节点而不删除 PVC,这样 3 个 pod 将分布在每个 3 个节点上。 I tried deleting pod but it creates on same node and not on new node(which is expected).我尝试删除 pod,但它在同一个节点上创建,而不是在新节点上创建(这是预期的)。 Can anyone please let me know if it is possible to move one pod to another node with out deleting PVC?谁能告诉我是否可以在不删除 PVC 的情况下将一个 pod 移动到另一个节点? is this achievable?这是可以实现的吗? or any alternate solution as I do not want to delete PVC.或任何替代解决方案,因为我不想删除 PVC。

It's not recommended to delete pods of a statefulset.不建议删除 statefulset 的 pod。 You can scale-down the statefulset to 2 replicas and then scale it up to 3.您可以将 statefulset 缩减为 2 个副本,然后将其扩展到 3 个。

kubectl get statefulsets <stateful-set-name>

kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>

You will need affinity你需要亲和力

And restart all statefulsets并重新启动所有状态集

kubectl rollout restart statefulset <stateful-set-name>

You can force a pod to be started on a different node by cordoning the node that the pod is running on and then redeploying the pod.您可以通过封锁运行 pod 的节点然后重新部署 pod 来强制在不同的节点上启动 pod。 That way kubernetes has to place it onto a different node.这样 kubernetes 必须将其放置到不同的节点上。 You can uncordon the node afterwards.之后您可以解除对节点的封锁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM