In Kubernetes, to reboot a pod or VM, you can either delete and recreate it to lose state or scale down the deployment’s replicas for a soft-reboot. Additionally, you can use virtctl to manage VMs.

k8s reboot pod and vm

to reboot you need to kill the pod/vmi and recreate it, thereby all its states will be lost.

1
2
3
kubectl delete pod <pod_name>
kubectl delete vmi <vmi_name>

for vmi there is an option called soft-reboot which is absent in pods. however the vm runner pod must not exit.

1
2
virtctl soft-reboot <vmi_name>

for pod you you can scale down the replicas of deployment (recommended), or kill the pod directly.

1
2
3
kubectl scale deployment <deployment_name> --replicas=0
kubectl scale deployment <deployment_name> --replicas=<original replica num>

for vm you are supposed to use virtctl

1
2
3
4
virtctl start <vm_name>
virtctl stop <vm_name>
virtctl restart <vm_name>

Comments