You need to restart all pods in a namespace without deleting the Deployment. What is the best approach?
- Use kubectl rollout restart ✓
- Restart the kubelet on all nodes
- Use kubectl delete pod to remove all pods
- Use kubectl scale to 0, then back to desired replicas
Correct answer: Use kubectl rollout restart
Option A is correct because 'kubectl rollout restart' triggers a rolling restart of all pods managed by a Deployment without deleting the Deployment object itself, preserving the desired state and ensuring zero downtime during the restart cycle. Option B is incorrect because restarting the kubelet on all nodes is a disruptive node-level operation that affects every workload on those nodes and is far broader than restarting pods in a single namespace. Option C is incorrect because manually deleting pods forces an immediate recreation but does not use the rolling update mechanism, potentially causing downtime and bypassing Deployment-managed rollout controls. Option D is incorrect because scaling to zero and back is a valid workaround but causes a full outage period at zero replicas and is less clean and less idiomatic than 'kubectl rollout restart', which was introduced precisely for this use case.
Topic: · kubectl, deployments, rolling restart, kubernetes operations