Bird
Raised Fist0
GCPcloud~10 mins

Revision management in GCP - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Revision management
Create initial revision
↓
Deploy revision to service
↓
Make changes to config/code
↓
Create new revision
↓
Deploy new revision
↓
Traffic shifts to new revision
↓
Optionally rollback to previous revision
↓
Manage multiple revisions
Revision management tracks versions of deployed code/configuration, allowing updates and rollbacks safely.
Execution Sample
GCP
gcloud run deploy myservice --image gcr.io/myproject/myimage:v1
# Deploys revision-1

gcloud run deploy myservice --image gcr.io/myproject/myimage:v2
# Deploys revision-2

gcloud run services update-traffic myservice --to-revisions revision-1=100
# Rollback traffic to revision-1
Deploys two revisions of a Cloud Run service and rolls back traffic to the first revision.
Process Table
StepActionRevision CreatedTraffic AllocationResult
1Deploy service with image:v1revision-1revision-1=100%Service running revision-1
2Deploy service with image:v2revision-2revision-2=100%Service updated to revision-2
3Update traffic to revision-1nonerevision-1=100%Traffic rolled back to revision-1
4Deploy service with image:v3revision-3revision-3=100%Service updated to revision-3
5Split traffic between revision-3 and revision-1nonerevision-3=50%, revision-1=50%Traffic split between revisions
6Delete old revision-2noneunchangedrevision-2 removed
7No further changesnoneunchangedStable traffic and revisions
💡 No more changes; revisions managed with traffic control and cleanup
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6Final
Revisionsnone[revision-1][revision-1, revision-2][revision-1, revision-2][revision-1, revision-2, revision-3][revision-1, revision-2, revision-3][revision-1, revision-3][revision-1, revision-3]
Trafficnonerevision-1=100%revision-2=100%revision-1=100%revision-3=100%revision-3=50%, revision-1=50%revision-3=50%, revision-1=50%revision-3=50%, revision-1=50%
Key Moments - 3 Insights
Why does deploying a new image create a new revision instead of replacing the old one?
Each deployment creates a new revision to keep history and allow rollback, as shown in steps 1, 2, and 4 where new revisions are created without deleting old ones.
How does traffic shifting work between revisions?
Traffic can be split or shifted fully between revisions without redeploying, as in step 5 where traffic is split 50/50 between revision-3 and revision-1.
What happens if you delete a revision that still has traffic?
Deleting a revision with traffic is not allowed or causes errors; traffic must be shifted away first, as shown in step 6 where revision-2 is deleted only after traffic moved away.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step is traffic rolled back to revision-1?
AStep 3
BStep 2
CStep 5
DStep 6
💡 Hint
Check the 'Traffic Allocation' column for 100% traffic to revision-1
According to variable_tracker, how many revisions exist after step 4?
A1
B3
C2
D4
💡 Hint
Look at the 'Revisions' row after step 4
If traffic was not shifted before deleting revision-2, what would happen?
ARevision-2 would be deleted successfully
BTraffic would automatically move to revision-1
CDeletion would fail or cause errors
DRevision-3 would be deleted instead
💡 Hint
Refer to key_moments about deleting revisions with traffic
Concept Snapshot
Revision management in GCP Cloud Run:
- Each deploy creates a new revision
- Traffic can be shifted or split between revisions
- Rollbacks done by shifting traffic back
- Old revisions can be deleted after traffic moves
- Enables safe updates and quick recovery
Full Transcript
Revision management in Google Cloud Platform involves creating new versions called revisions each time you deploy a service update. These revisions keep a history of your service states. You can control which revision receives user traffic, allowing you to shift traffic gradually or rollback to a previous version if needed. Deleting old revisions is possible only after traffic is moved away from them. This process ensures safe updates and easy recovery from issues.

Practice

(1/5)
1. What is the main purpose of revision management in Google Cloud services?
easy
A. To track and control different versions of your cloud services
B. To increase the storage capacity of your cloud database
C. To monitor network traffic between services
D. To automatically scale the number of virtual machines

Solution

  1. Step 1: Understand revision management concept

    Revision management is about keeping track of different versions of your cloud services.
  2. Step 2: Identify the main goal

    The main goal is to control versions for safe updates and rollbacks.
  3. Final Answer:

    To track and control different versions of your cloud services -> Option A
  4. Quick Check:

    Revision management = version control [OK]
Hint: Revision management means version control of services [OK]
Common Mistakes:
  • Confusing revision management with scaling
  • Thinking it manages storage or network
  • Mixing it with monitoring tools
2. Which gcloud command is used to list all revisions of a Cloud Run service named my-service?
easy
A. gcloud run revisions list --service=my-service
B. gcloud run services list --revisions=my-service
C. gcloud revisions describe my-service
D. gcloud run deploy revisions --service=my-service

Solution

  1. Step 1: Identify correct command structure

    The command to list revisions uses gcloud run revisions list with the service flag.
  2. Step 2: Match service name parameter

    Using --service=my-service correctly specifies the service.
  3. Final Answer:

    gcloud run revisions list --service=my-service -> Option A
  4. Quick Check:

    List revisions = gcloud run revisions list --service [OK]
Hint: List revisions with 'gcloud run revisions list --service' [OK]
Common Mistakes:
  • Using 'services list' instead of 'revisions list'
  • Mixing 'describe' with listing
  • Wrong command order or flags
3. Given the following commands, what will be the output of gcloud run revisions list --service=my-app after deploying twice?
gcloud run deploy my-app --image=image:v1 --no-traffic
gcloud run deploy my-app --image=image:v2 --no-traffic
medium
A. One revision with image:v2
B. No revisions because traffic is zero
C. Two revisions: one with image:v1 and one with image:v2
D. Error because --no-traffic disables revisions

Solution

  1. Step 1: Understand deployment with --no-traffic

    Deploying with --no-traffic creates a new revision but does not route traffic to it.
  2. Step 2: Analyze multiple deployments

    Deploying twice with different images creates two separate revisions.
  3. Final Answer:

    Two revisions: one with image:v1 and one with image:v2 -> Option C
  4. Quick Check:

    Each deploy creates a revision even with no traffic [OK]
Hint: Each deploy creates a revision, traffic doesn't affect revision count [OK]
Common Mistakes:
  • Assuming no traffic means no revision
  • Thinking only latest revision exists
  • Confusing traffic routing with revision creation
4. You deployed a new revision but it is not receiving traffic. Which command fixes this by routing 100% traffic to the latest revision named my-app-00002?
medium
A. gcloud run revisions set-traffic my-app-00002 --percent=100
B. gcloud run services update-traffic my-app --to-revisions my-app-00002=100
C. gcloud run services update my-app --traffic my-app-00002=100
D. gcloud run services update-traffic my-app --to-revision my-app-00002=100

Solution

  1. Step 1: Identify correct command to update traffic

    The command to update traffic routing is gcloud run services update-traffic.
  2. Step 2: Use correct syntax for traffic split

    The syntax --to-revisions my-app-00002=100 routes 100% traffic to that revision.
  3. Final Answer:

    gcloud run services update-traffic my-app --to-revisions my-app-00002=100 -> Option B
  4. Quick Check:

    Update traffic with 'services update-traffic' and '--to-revisions' [OK]
Hint: Use 'gcloud run services update-traffic' with '--to-revisions' [OK]
Common Mistakes:
  • Using 'update' instead of 'update-traffic'
  • Wrong flag names like '--percent'
  • Trying to set traffic on revision directly
5. You want to roll back your Cloud Run service web-app to a previous revision web-app-00003 safely without downtime. Which sequence of commands achieves this?
hard
A. gcloud run deploy web-app --image=web-app-00003
B. gcloud run services update web-app --revision web-app-00003
C. gcloud run revisions delete web-app-00004 && gcloud run services update-traffic web-app --to-revisions web-app-00003=100
D. gcloud run services update-traffic web-app --to-revisions web-app-00003=100

Solution

  1. Step 1: Understand rollback via traffic routing

    Rolling back means routing traffic back to an existing previous revision.
  2. Step 2: Use traffic update command

    Use gcloud run services update-traffic to send 100% traffic to the old revision.
  3. Step 3: Avoid deleting revisions or redeploying

    Deleting or redeploying is unnecessary and may cause downtime.
  4. Final Answer:

    gcloud run services update-traffic web-app --to-revisions web-app-00003=100 -> Option D
  5. Quick Check:

    Rollback by routing traffic to old revision [OK]
Hint: Rollback by updating traffic to old revision, no redeploy needed [OK]
Common Mistakes:
  • Trying to redeploy old revision as image
  • Deleting newer revisions unnecessarily
  • Using wrong commands to update revision
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard