I'm trying to get all the deployments of a namespace to be restarted for implementation reasons.
I'm using "kubectl rollout -n <namespace> restart deploy" and it works perfectly, but I'm not sure it that command causes downtime or if it works as the "rollout update", applying the restart one by one, keeping my services up.
Does anyone know?
In the documentation I can only find this:
Operation | Syntax | Description |
---|---|---|
rollout | kubectl rollout SUBCOMMAND options | Manage the rollout of a resource. Valid resource types include: deployments, daemonsets and statefulsets. |
But I can't find details about the specific "rollout restart deploy".
I need to make sure it doesn't cause downtime. Right now is very hard to tell, because the restart process is very quick.
Update: I know that for one specific deployment (kubectl rollout restart deployment/name), it works as expected and doesn't cause downtime, but I need to apply it to all the namespace (without specifying the deployment) and that's the case I'm not sure about.
kubectl rollout restart deploy -n namespace1
will restart all deployments in specified namespace with zero downtime.
Restart command will work as follows:
Add readiness probes to your deployments to configure initial delays.
@pcsutar 's answer is almost correct. kubectl rollout restart $resourcetype $resourcename
restarts your deployment, daemonset or stateful set according to the its update strategy. so if it is set to rollingUpdate
it will behave exactly as the above answer:
1) After restart it will create new pods for a each deployments 2) Once new pods are up (running and ready) it will terminate old pods
Add readiness probes to your deployments to configure initial delays.
However, if the strategy for example is type: recreate
all the currently running pods belonging to the deployment will be terminated before new pods will be spun up!