大网数据广告活动
服务器运维问答

How can I restart or reset the K3s cluster pods

· 52CE 我爱测

I have a k3s ( v1.21.1 + k3s1 ) cluster with following pods: kube-system pod/calico-node-xxxx kube-system pod/calico-kube-controllers-xxxxxx kube-system pod/metrics-server-xxxxx kube-system pod/local-path-provisioner-xxxxx kube-s…

问题原文

原帖链接 · solveit · CC BY-SA 4.0

I have a k3s (v1.21.1+k3s1) cluster with following pods:

kube-system   pod/calico-node-xxxx                          
kube-system   pod/calico-kube-controllers-xxxxxx   
kube-system   pod/metrics-server-xxxxx
kube-system   pod/local-path-provisioner-xxxxx
kube-system   pod/coredns-xxxxx

How can I restart (stop and start the pods again) the pods either with command (kubectl maybe) or any script?

已采纳解答

原帖链接 · matt_j · CC BY-SA 4.0

Kubernetes doesn't support stopping/pausing the current state of Pods. However, you can perform a rollout restart of the Deployment/DaemonSet with the kubectl rollout restart command (see: the Kubectl Reference Docs).

To restart all Deployments and DaemonSets in the kube-system namespace, you can use the following command:

# kubectl -n kube-system rollout restart daemonsets,deployments
daemonset.apps/calico-node restarted
deployment.apps/local-path-provisioner restarted
deployment.apps/coredns restarted
deployment.apps/metrics-server restarted
deployment.apps/calico-kube-controllers restarted

As you probably noticed from the output above, the calico-node is a DaemonSet and rest of the Pods are managed by Deployments.

If you want, you can restart specific Deployment/Daemonset:

# kubectl -n kube-system rollout restart deployment metrics-server
deployment.apps/metrics-server restarted
# kubectl get pod -n kube-system | grep metrics-server
metrics-server-6bd8786b6c-74qlt            1/1     Running       0          2s
metrics-server-647d5b4475-ch9zj            1/1     Terminating   0          28s

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-08-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。