- How to deploy a simple Deployment and Service
- How RollingUpdate preserves availability during updates
- How Recreate causes downtime by terminating all pods before creating new ones
strategy section. Kubernetes defaults to the RollingUpdate strategy when strategy is not specified.
If you require zero-downtime updates, RollingUpdate is the default and preferred choice. The Recreate strategy will terminate all existing pods before creating new ones, which causes an interruption in service.
1) Clone the repo and apply resources
Run the commands below to prepare the demo namespace and apply the manifests:
2) Poll the endpoint continuously to observe updates
Use the following shell loop to poll the NodePort and colorize v1 / v2 responses. Replace the NodePort (32431) if yours differs.3) Rolling update (no downtime)
Because RollingUpdate is the default strategy, updating the Deployment image will perform a rolling upgrade: new pods are created and traffic shifts gradually from old pods to new pods. Update the image to v2 using kubectl set image:4) Recreate strategy (introduce downtime)
To demonstrate downtime, change the Deployment strategy to Recreate. Edit the deployment:strategy section in the spec:
Using the Recreate strategy will cause downtime because all old pods are terminated before new pods are created. Use Recreate only when you must avoid running multiple versions concurrently and can tolerate interruptions.
Comparison: RollingUpdate vs Recreate
References
Summary- RollingUpdate (default): incrementally updates pods and preserves availability.
- Recreate: shuts down all existing pods first, then starts new ones — which causes downtime.