kubernetes群集 - 重新启动后不重新启动容器

发布于 2025-01-22 11:51:54 字数 226 浏览 0 评论 0 原文

我在家里有两台裸金属机器的Kubernetes群集设置。 我使用kubespray安装了这两个,并且它在幕后使用了kubeadm。

我遇到的问题是,群集中的所有容器都有一个restartpolicy:不,当我重新启动主节点时,这会使我的群集断开。

我必须为“ Kube-System”名称空间中的所有容器手动运行“ Docker容器启动”,以使其在重新启动后起作用。

有人知道问题可能来自哪里吗?

I have a kubernetes cluster setup at home on two bare metal machines.
I used kubespray to install both and it uses kubeadm behind the scenes.

The problem I encounter is that all containers within the cluster have a restartPolicy: no which makes my cluster break when I restart the main node.

I have to manually run "docker container start" for all containers in "kube-system" namespace to make it work after reboot.

Does anyone have an idea where the problem might be coming from ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

‘画卷フ 2025-01-29 11:51:54

docker提供重新启动策略当他们退出时或Docker重新启动时自动启动。在这里,您的容器具有重新启动策略-NO ,这意味着在任何情况下,此策略将永远不会自动启动该容器。

您需要将重新启动策略更改为总是,如果该容器停止,它将重新启动容器。如果手动停止,则仅在Docker Daemon重新启动或手动重新启动容器本身时才重新启动。

您可以使用 Docker Update 更改现有容器的重新启动策略。将容器的名称传递给命令。 Docker PS -A 。

docker update --restart=always <CONTAINER NAME>

您可以通过运行

  • 重新启动策略仅在容器成功启动后才生效。在这种情况下,启动成功意味着容器至少启动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 running docker ps -a.

docker update --restart=always <CONTAINER NAME>

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.

孤单情人 2025-01-29 11:51:54

我正在回答我的问题:

并不是很清楚,但是我在谈论管理整个群集的kube系统吊舱,当机器重新启动时,它应该自动启动。

事实证明,这些POD(例如:code-dns,kube-proxy等)具有重新启动的策略为“ no”,而在节点上,当您重新启动节点时,节点上的kubelet服务都插入了整个群集。

在我的情况下,由于缺少CRI-DOCKERD过程,kubelet无法启动。
检查我在kubespray上打开的问题:

验证库贝特日志的完成程度如下:

journalctl -u kubelet -f

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:

journalctl -u kubelet -f
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文