Deploying new Cloud Run application versions

5 minutes 5 Questions

Deploying new Cloud Run application versions is a critical skill for Google Cloud Associate Cloud Engineer certification. Cloud Run is a fully managed serverless platform that automatically scales your containerized applications. To deploy a new version, you first need to build your container image and push it to Google Container Registry (GCR) or Artifact Registry. Use the command 'gcloud builds submit --tag gcr.io/PROJECT_ID/SERVICE_NAME' to build and push your image. For deployment, execute 'gcloud run deploy SERVICE_NAME --image gcr.io/PROJECT_ID/SERVICE_NAME --region REGION --platform managed'. This command creates a new revision of your service. Each deployment generates a unique revision that can receive traffic. Traffic management is essential when deploying new versions. By default, Cloud Run routes 100% of traffic to the latest revision. For gradual rollouts, use traffic splitting with 'gcloud run services update-traffic SERVICE_NAME --to-revisions=REVISION1=50,REVISION2=50'. This allows canary deployments where you can test new versions with a percentage of users before full rollout. Key configuration options during deployment include setting memory limits (--memory), CPU allocation (--cpu), maximum instances (--max-instances), and environment variables (--set-env-vars). You can also configure concurrency settings to control how many requests each container instance handles simultaneously. For production environments, implement proper CI/CD pipelines using Cloud Build triggers. Connect your source repository to automatically build and deploy when code changes are pushed. This ensures consistent, repeatable deployments. Monitoring deployed versions is crucial. Use Cloud Logging and Cloud Monitoring to track performance metrics, error rates, and latency. If issues arise with a new version, you can quickly rollback by redirecting all traffic to a previous stable revision using traffic management commands. Best practices include tagging images with version numbers, using service accounts with minimal required permissions, and testing thoroughly in staging environments before production deployment.

Deploying New Cloud Run Application Versions

Why It Is Important

Deploying new Cloud Run application versions is a critical skill for cloud engineers because it enables continuous delivery of applications while maintaining high availability. Cloud Run's serverless architecture allows teams to push updates, fix bugs, and release new features with minimal downtime. Understanding version management ensures you can implement safe deployment strategies, perform rollbacks when necessary, and manage traffic between different versions of your application.

What It Is

Cloud Run is a fully managed serverless platform that runs stateless containers. When you deploy a new version of your application, Cloud Run creates a new revision. A revision is an immutable snapshot of your container image along with its configuration settings. Each revision can serve traffic independently, and you can control how traffic is distributed across multiple revisions.

Key concepts include:
- Revisions: Immutable versions of your service created with each deployment
- Traffic Splitting: Distributing requests between different revisions
- Tags: Named URLs pointing to specific revisions for testing
- Rollbacks: Redirecting traffic back to a previous revision

How It Works

When deploying a new Cloud Run version, you can use the following methods:

Using gcloud CLI:
gcloud run deploy SERVICE_NAME --image IMAGE_URL --region REGION

By default, new deployments receive 100% of traffic. To implement gradual rollouts:

gcloud run services update-traffic SERVICE_NAME --to-revisions=NEW_REVISION=10,OLD_REVISION=90

This splits traffic with 10% going to the new revision and 90% to the old one.

Using Tags for Testing:
gcloud run services update-traffic SERVICE_NAME --to-tags=test=NEW_REVISION

This creates a unique URL for testing the new revision before sending production traffic.

Performing Rollbacks:
gcloud run services update-traffic SERVICE_NAME --to-revisions=PREVIOUS_REVISION=100

Deployment Strategies

- All-at-once: Default behavior where new revision gets 100% traffic
- Canary Deployments: Send small percentage of traffic to new revision first
- Blue-Green: Use tags to test new version, then switch traffic entirely

Exam Tips: Answering Questions on Deploying New Cloud Run Application Versions

1. Remember revision immutability: Once a revision is created, it cannot be modified. Any change requires a new deployment creating a new revision.

2. Traffic splitting percentages: When asked about gradual rollouts, remember that traffic percentages must total 100% across all revisions.

3. Know the difference between revisions and tags: Revisions are actual deployments, while tags are named references that provide specific URLs for accessing particular revisions.

4. Rollback scenarios: If a question mentions application errors after deployment, the solution involves redirecting traffic to a previous healthy revision using traffic management commands.

5. Default behavior awareness: New deployments automatically route 100% traffic unless you specify otherwise with the --no-traffic flag.

6. Container image requirements: Cloud Run requires container images stored in Artifact Registry or Container Registry. Questions may test your knowledge of valid image sources.

7. Configuration changes create new revisions: Modifying environment variables, memory limits, or CPU allocation will create a new revision even with the same container image.

8. Zero-downtime deployments: Cloud Run handles version transitions seamlessly. Look for answers that leverage this built-in capability rather than manual intervention.

9. Testing before production: When questions ask about validating new versions safely, look for answers involving tagged revisions that allow testing via unique URLs.
Test mode:
More Deploying new Cloud Run application versions questions
30 questions (total)

Other Ensuring Successful Operation of a Cloud Solution concepts

Active Assist for resource utilizationAdding a subnet to an existing VPCAdding custom static routes in a VPCAdding, editing, and removing node poolsAdjusting application traffic splittingAutoscaling node poolsBacking up and restoring database instancesCloud ProfilerCloud TraceConfiguring and deploying Ops AgentConfiguring audit logsConfiguring autoscaling for Cloud RunConfiguring GKE to access Artifact RegistryConfiguring log bucketsCreating and viewing imagesCreating Cloud Monitoring alertsCreating Cloud Monitoring custom metricsEstimating costs of data storage resourcesExecuting queries to retrieve dataExpanding a subnet for more IP addressesExporting logs to BigQueryExporting logs to external systemsGemini Cloud Assist for Cloud MonitoringGKE nodes, Pods, and ServicesGoogle Cloud Managed Service for PrometheusHorizontal Pod autoscalingIndex advisorIngesting custom metrics from applicationsKubernetes PodsKubernetes ServicesKubernetes StatefulSetsLog analyticsLog routersManaging GKE Autopilot Pod resource requestsManaging objects in Cloud Storage bucketsObject lifecycle management policiesPersonalized Service Health dashboardQuerying AlloyDBQuerying BigQueryQuerying BigtableQuerying Cloud SQLQuerying FirestoreQuerying SpannerQuery InsightsRemotely connecting to Compute Engine instancesReserving static external IP addressesReserving static internal IP addressesReviewing job status (Dataflow, BigQuery)Scheduling snapshotsSecuring objects in Cloud Storage bucketsUsing Database CenterVertical Pod autoscalingViewing and filtering logs in Cloud LoggingViewing GKE cluster inventoryViewing log message detailsViewing running Compute Engine instancesWorking with Cloud DNSWorking with Cloud NATWorking with GKE node poolsWorking with Kubernetes resourcesWorking with snapshots and images