A rolling update is a deployment strategy that gradually replaces old application instances with new ones while keeping the application available to users. Instead of stopping all running instances at once, the platform updates them in small batches, helping achieve minimal or zero downtime during deployments. This approach is commonly used in Kubernetes, cloud-native environments, and CI/CD pipelines.
Steps to Perform a Rolling Update in Kubernetes
1. Prepare a New Application Version
Build and push the updated container image to your container registry. Ensure the new version has been tested before deployment.
2. Update the Deployment
Modify the Deployment manifest with the new container image or update it directly using kubectl.
Example:
kubectl set image deployment/my-app my-app=my-app:v2
This command triggers a rolling update automatically because the Deployment's pod template has changed.
3. Monitor the Rollout
Track the progress of the deployment using:
kubectl rollout status deployment/my-app
This command shows whether the rollout is progressing successfully or if any issues have occurred.
4. Verify the Updated Pods
Check that the new pods are running and healthy:
kubectl get pods
kubectl get deployments
You can also inspect pod details to confirm the updated image version.
5. Roll Back if Necessary
If the new release introduces problems, Kubernetes allows you to revert to the previous stable version:
kubectl rollout undo deployment/my-app
Rollback is one of the key advantages of using Deployments for application management.
Best Practices for Rolling Updates
- Configure readiness and liveness probes so traffic is sent only to healthy pods.
- Use multiple replicas to maintain service availability during updates.
- Adjust
maxSurge and maxUnavailable to control how many pods are created or removed during the rollout.
- Monitor application logs, metrics, and alerts throughout the deployment process.
- Test updates in a staging environment before deploying to production.
Benefits of Rolling Updates
Rolling updates offer several advantages:
- Near-zero downtime during deployments.
- Continuous availability for end users.
- Safer application upgrades.
- Easy rollback if issues are detected.
- Better support for continuous integration and continuous delivery (CI/CD).
Conclusion
Rolling updates are the default deployment strategy in Kubernetes because they provide a reliable way to deploy new application versions without interrupting service. By gradually replacing old pods with new ones, monitoring rollout progress, and using health checks and rollback capabilities, teams can release software more safely and maintain a highly available production environment.