MIG Rolling Updates and Canary Deployments
What you'll learn: How to safely update instances in a Managed Instance Group (MIG) using rolling updates and canary deployment patterns.
The Core Idea
When you need to update the software, configuration, or image on instances in your MIG, you don't want to take everything down at once or risk breaking your entire fleet. Rolling updates gradually replace old instances with new ones, while canary deployments test changes on a small subset before rolling out to everyone.
Think of it like updating a fleet of delivery trucks: you wouldn't swap all engines simultaneously. You'd update a few, monitor performance, then continue—or roll back if something's wrong.
Update Policy Configuration
GCP lets you control how updates happen:
- Max surge: How many extra instances can exist temporarily during the update (e.g., create 2 new before deleting old ones)
- Max unavailable: How many instances can be offline simultaneously (e.g., 1 at a time to maintain availability)
Setting maxSurge=3 and maxUnavailable=0 means you temporarily run extra capacity while updating—zero downtime, but higher cost briefly. Setting maxSurge=0 and maxUnavailable=2 saves cost but accepts some instances being down.
Canary Updates
A canary update deploys the new version to a small percentage of instances first (e.g., 10%). You monitor metrics, health checks, and errors. If the canary looks healthy, you proceed with the full rollout. If not, you roll back before affecting most users.
This is your safety net—catching bugs before they become disasters.
Key Takeaway: MIG rolling updates use maxSurge and maxUnavailable to control update speed and availability, while canary deployments test changes on a small subset before full rollout, minimizing risk during infrastructure changes.