Skip to content

Optimize GCP Prod Environment: Minimal Sizing, Deployment Resilience, and Registry Integration#8

Merged
benjamin-747 merged 1 commit intogitmono-dev:mainfrom
WiedersehenM:feat/gcp-cloudrun-lb-certmanager
Feb 10, 2026
Merged

Optimize GCP Prod Environment: Minimal Sizing, Deployment Resilience, and Registry Integration#8
benjamin-747 merged 1 commit intogitmono-dev:mainfrom
WiedersehenM:feat/gcp-cloudrun-lb-certmanager

Conversation

@WiedersehenM
Copy link
Contributor

Overview

This Pull Request optimizes the GCP production deployment configuration to align with cost‑efficiency requirements while resolving critical deployment blockers. The primary focus is on utilizing the smallest possible instance sizes, removing high-availability overhead, and ensuring reliable image delivery and database failover.

Key Changes

1. Registry & Image Management

  • Artifact Registry Module: Re-integrated the artifact_registry module. This is now a requirement as Cloud Run cannot pull directly from AWS ECR Public.
  • Automated Image Sync: Added deployment/scripts/sync_images_to_ar.sh to facilitate the migration of images from ECR to GCP.
  • Dynamic Image Paths: Updated main.tf to auto-construct full image URLs using project_id, image_name, and image_tag. This eliminates the need to manually update long registry strings in terraform.tfvars.

2. Database & Cache Optimization (Cost Control)

  • Cloud SQL Tier Fix: Added edition = "ENTERPRISE" support to the cloud_sql module. This allows the use of the db-f1-micro tier, which is restricted in the default ENTERPRISE_PLUS edition.
  • Redis Downsizing: Defaulted Redis to the BASIC tier with 1GB memory to minimize hourly costs.
  • SQLite Fallback: Configured backend environment variables to allow a graceful fallback to SQLite in /tmp. This ensures the application can start even if Cloud SQL peering is restricted by project-level IAM permissions.

Motivation

These updates cater to a lab/teaching environment where minimizing GCP billing and reducing deployment friction are essential. The new configuration provides a more resilient "out-of-the-box" experience by handling common Cloud Run and Cloud SQL permission issues gracefully.

…ployment

- Minimizes Cloud SQL and Redis instance sizes and removes HA/replicas.
- Adds Artifact Registry support and image sync script to bypass Cloud Run source restrictions.
- Implements SQLite fallback config for backend startup stability.
- Simplifies terraform.tfvars by leveraging sane defaults in variables.tf.

Signed-off-by: Hongze Gao <15101764808@163.com>
@benjamin-747 benjamin-747 added this pull request to the merge queue Feb 10, 2026
Merged via the queue into gitmono-dev:main with commit caa54ee Feb 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants