在 pod 内重启容器 [英] Restart container within pod
问题描述
我有一个带有 2 个容器的 pod test-1495806908-xn5jn
.我想重新启动其中一个名为 container-test
的工具.是否可以在 pod 中重新启动单个容器以及如何重新启动?如果没有,我如何重新启动 pod?
I have a pod test-1495806908-xn5jn
with 2 containers. I'd like to restart one of them called container-test
. Is it possible to restart a single container within a pod and how? If not, how do I restart the pod?
Pod 是使用 deployment.yaml
创建的:
The pod was created using a deployment.yaml
with:
kubectl create -f deployment.yaml
推荐答案
是否可以重启单个容器
Is it possible to restart a single container
不是通过 kubectl
,尽管根据集群的设置,您可以作弊"和 docker kill the-sha-goes-here
,这将导致 kubelet重启失败"的容器(当然,假设 Pod 的重启策略说这是它应该做的)
Not through kubectl
, although depending on the setup of your cluster you can "cheat" and docker kill the-sha-goes-here
, which will cause kubelet to restart the "failed" container (assuming, of course, the restart policy for the Pod says that is what it should do)
如何重新启动 Pod
这取决于 Pod 是如何创建的,但是根据您提供的 Pod 名称,它似乎在 ReplicaSet 的监督之下,因此您只需 kubectl delete pod test-1495806908-xn5jn
并且 kubernetes 将在它的位置创建一个新的(新的 Pod 将有一个不同的名称,所以永远不要期望 kubectl get pods
返回 test-1495806908-xn5jn
再次)
That depends on how the Pod was created, but based on the Pod name you provided, it appears to be under the oversight of a ReplicaSet, so you can just kubectl delete pod test-1495806908-xn5jn
and kubernetes will create a new one in its place (the new Pod will have a different name, so do not expect kubectl get pods
to return test-1495806908-xn5jn
ever again)
这篇关于在 pod 内重启容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!