kubernetes群集 - 重新启动后不重新启动容器
我在家里有两台裸金属机器的Kubernetes群集设置。 我使用kubespray安装了这两个,并且它在幕后使用了kubeadm。
我遇到的问题是,群集中的所有容器都有一个restartpolicy:不,当我重新启动主节点时,这会使我的群集断开。
我必须为“ Kube-System”名称空间中的所有容器手动运行“ Docker容器启动”,以使其在重新启动后起作用。
有人知道问题可能来自哪里吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
docker提供重新启动策略当他们退出时或Docker重新启动时自动启动。在这里,您的容器具有重新启动策略-NO ,这意味着在任何情况下,此策略将永远不会自动启动该容器。
您需要将重新启动策略更改为总是,如果该容器停止,它将重新启动容器。如果手动停止,则仅在Docker Daemon重新启动或手动重新启动容器本身时才重新启动。
您可以使用
Docker Update
更改现有容器的重新启动策略。将容器的名称传递给命令。 Docker PS -A 。您可以通过运行
重新启动策略仅在容器成功启动后才生效。在这种情况下,启动成功意味着容器至少启动10秒,而Docker已经开始监视它。这样可以防止一个根本无法进入重新启动循环的容器。
如果您手动停止容器,则忽略其重新启动策略,直到Docker Daemon重新启动或手动重新启动容器为止。这是防止重新启动循环的另一种尝试。
Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Here your containers have the restart policy - no which means this policy will never automatically start the container under any circumstance.
You need to change the restart policy to Always which restarts the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted.
You can change the restart policy of an existing container using
docker update
. Pass the name of the container to the command. You can find container names by runningdocker ps -a
.Restart policy details:
Keep the following in mind when using restart policies:
A restart policy only takes effect after a container starts successfully. In this case, starting successfully means that the container is up for at least 10 seconds and Docker has started monitoring it. This prevents a container which does not start at all from going into a restart loop.
If you manually stop a container, its restart policy is ignored until the Docker daemon restarts or the container is manually restarted. This is another attempt to prevent a restart loop.
我正在回答我的问题:
并不是很清楚,但是我在谈论管理整个群集的kube系统吊舱,当机器重新启动时,它应该自动启动。
事实证明,这些POD(例如:code-dns,kube-proxy等)具有重新启动的策略为“ no”,而在节点上,当您重新启动节点时,节点上的kubelet服务都插入了整个群集。
在我的情况下,由于缺少CRI-DOCKERD过程,kubelet无法启动。
检查我在kubespray上打开的问题:
验证库贝特日志的完成程度如下:
I am answering my question:
It wasn't probably very clear but I was talking about the kube-system pods that manage the whole cluster and that should automatically start when the machine restarts.
It turns out those pods (ex: code-dns, kube-proxy, etc) have a restart policy of "no" intentionally and it is the kubelet service on the node that spins up the whole cluster when you restart your node.
https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
In my case kubelet could not start due to missing cri-dockerd process.
Check the issue I opened at kubespray:
Verifying the kubelet logs is done like so: