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?
Kubernetes doesn't support stopping/pausing the current state of Pods. However, you can perform a rollout restart of the
Deployment
/DaemonSet
with thekubectl rollout restart
command (see: the Kubectl Reference Docs).To restart all
Deployments
andDaemonSets
in thekube-system
namespace, you can use the following command:As you probably noticed from the output above, the
calico-node
is aDaemonSet
and rest of the Pods are managed byDeployments
.If you want, you can restart specific
Deployment
/Daemonset
: