Score:2

How can I restart or reset the K3s cluster pods

ar flag

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?

Score:3
in flag

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
Wytrzymały Wiktor avatar
it flag
Hello @solveit. Have you managed to make it work?
solveit avatar
ar flag
@WytrzymałyWiktor : Yes it worked for me. Thanks a lot
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.