如何从 Kubernetes 主节点删除一个 pod?
How to delete a pod from Kubernetes master node?
有谁知道如何从kubernetes主节点删除pod?我在裸机 ubuntu 服务器上有一个主节点。当我尝试使用“kubectl delete pod ..”删除它或从那里强制删除时:https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/ 它不起作用。 pod 一次又一次地创建...
Statefulsets 中的 pods 由 ReplicaSets 管理,如果规范中定义的当前副本和所需副本不匹配,将再次重新创建。
您 link 阅读的文档提供了有关如何终止 pods 强制避免正常关闭行为的说明,根据应用程序的不同,该行为可能会产生意外行为。
link 明确指出 pods 将在以下部分重新创建:
Force deletions do not wait for confirmation from the kubelet that the Pod has been terminated. Irrespective of whether a force deletion is successful in killing a Pod, it will immediately free up the name from the apiserver. This would let the StatefulSet controller create a replacement Pod with that same identity; this can lead to the duplication of a still-running Pod, and if said Pod can still communicate with the other members of the StatefulSet, will violate the at most one semantics that StatefulSet is designed to guarantee.
如果您希望停止 pods 并且不创建 Statefulset 的新 pods,您需要通过将副本更改为 0 来缩减 Statefulset。
您可以阅读 how to scale the Statefulset replicas 的官方文档。
弄清楚如何杀死 pod 的关键是了解它是如何创建的。例如,如果 pod 是声明的副本数为 1 的部署的一部分,一旦您终止/强制终止,Kubernetes 会检测到所需状态(部署配置中定义的副本数)与当前状态之间的不匹配,并且将创建一个新的 pod 来替换已删除的 pod - 因此在此示例中,您需要将部署扩展到 0 或删除部署。
如果我们需要杀死任何 pod,我们可以缩小副本集。
kubectl scale deploy <deployment_name> --replicas=<expected_no_of_replicas>
删除 pods 的方式取决于您创建它的方式。如果您单独创建它(不是 ReplicaSet/ReplicationController/Deployment
的一部分),那么您可以直接删除 pod。否则唯一要删除的选项是 scale
选项。在生产设置中,我认为全部都在使用 ReplicaSet/ReplicationController/Deployment
中的 Deployment
选项(请参阅文档并了解所有这三个选项之间的区别)
有谁知道如何从kubernetes主节点删除pod?我在裸机 ubuntu 服务器上有一个主节点。当我尝试使用“kubectl delete pod ..”删除它或从那里强制删除时:https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/ 它不起作用。 pod 一次又一次地创建...
Statefulsets 中的 pods 由 ReplicaSets 管理,如果规范中定义的当前副本和所需副本不匹配,将再次重新创建。
您 link 阅读的文档提供了有关如何终止 pods 强制避免正常关闭行为的说明,根据应用程序的不同,该行为可能会产生意外行为。
link 明确指出 pods 将在以下部分重新创建:
Force deletions do not wait for confirmation from the kubelet that the Pod has been terminated. Irrespective of whether a force deletion is successful in killing a Pod, it will immediately free up the name from the apiserver. This would let the StatefulSet controller create a replacement Pod with that same identity; this can lead to the duplication of a still-running Pod, and if said Pod can still communicate with the other members of the StatefulSet, will violate the at most one semantics that StatefulSet is designed to guarantee.
如果您希望停止 pods 并且不创建 Statefulset 的新 pods,您需要通过将副本更改为 0 来缩减 Statefulset。
您可以阅读 how to scale the Statefulset replicas 的官方文档。
弄清楚如何杀死 pod 的关键是了解它是如何创建的。例如,如果 pod 是声明的副本数为 1 的部署的一部分,一旦您终止/强制终止,Kubernetes 会检测到所需状态(部署配置中定义的副本数)与当前状态之间的不匹配,并且将创建一个新的 pod 来替换已删除的 pod - 因此在此示例中,您需要将部署扩展到 0 或删除部署。
如果我们需要杀死任何 pod,我们可以缩小副本集。
kubectl scale deploy <deployment_name> --replicas=<expected_no_of_replicas>
删除 pods 的方式取决于您创建它的方式。如果您单独创建它(不是 ReplicaSet/ReplicationController/Deployment
的一部分),那么您可以直接删除 pod。否则唯一要删除的选项是 scale
选项。在生产设置中,我认为全部都在使用 ReplicaSet/ReplicationController/Deployment
中的 Deployment
选项(请参阅文档并了解所有这三个选项之间的区别)