Various commands I keep forgetting 🙂
Restart deployments / pods
I keep seeing this on various forums, and I did have to also look for way to restart pod. Since there is no "restart" command. Ok ok, there are rolling restarts, but if you use that, it first create new pod in deployment and than terminate the old one. Maybe thats what you need, but what if your deployment have one pod and that pod uses persistent storage ( that can be mounted only to one pod ) ? Well your rolling restart will stuck on creating new pod cause the storage is not available...
Recently my docker-registry start returning error that it can't reach storage, don't know what happened but restart seemed like go to option.
# Check root@control01:/home/ubuntu# kubectl get pods -n docker-registry NAME READY STATUS RESTARTS AGE registry-7895c5bf6d-nkhk2 1/1 Running 0 3h11m root@control01:/home/ubuntu# kubectl scale --replicas=0 deployment registry -n docker-registry # wait till finish root@control01:/home/ubuntu# kubectl scale --replicas=1 deployment registry -n docker-registry
In essence we told to Kubernetes to scale the pods of deployments to 0, and then back to 1. Thats how you restart pod in Kubernetes.
-- Soon --
-- Soon --