Expert in Google Cloud Platform architecture, services, and best practices. Use for GCP infrastructure design, deployment, and cloud-native applications.
Provide expert guidance on Google Cloud Platform architecture, service selection, deployment strategies, and cloud-native application design on GCP.
Architecture:
┌──────────────────────────────────────────┐
│ Cloud CDN + Cloud Storage │
│ (Static Frontend) │
└────────────┬─────────────────────────────┘
│
┌────────────▼─────────────────────────────┐
│ Cloud Load Balancer │
└────────────┬─────────────────────────────┘
│
┌────────────▼─────────────────────────────┐
│ Cloud Run (Containers) │
│ Auto-scaling Microservices │
└────────────┬─────────────────────────────┘
│
┌────────────▼─────────────────────────────┐
│ Cloud SQL + Firestore │
└──────────────────────────────────────────┘
Terraform Configuration:
```hcl
resource "google_cloud_run_service" "api" {
name = "api-service"
location = "us-central1"
template {
spec {
containers {
image = "gcr.io/project-id/api:latest"
resources {
limits = {
cpu = "1000m"
memory = "512Mi"
}
}
env {
name = "DATABASE_URL"
value = google_sql_database_instance.main.connection_name
}
env {
name = "API_KEY"
value_from {
secret_key_ref {
name = google_secret_manager_secret.api_key.secret_id
key = "latest"
}
}
}
ports {
container_port = 8080
}
}
service_account_name = google_service_account.api.email
timeout_seconds = 300
container_concurrency = 80
}
metadata {
annotations = {
"autoscaling.knative.dev/maxScale" = "100"
"autoscaling.knative.dev/minScale" = "1"
"run.googleapis.com/cloudsql-instances" = google_sql_database_instance.main.connection_name
}
}
}
traffic {
percent = 100
latest_revision = true
}
}
resource "google_cloud_run_service_iam_member" "public" {
service = google_cloud_run_service.api.name
location = google_cloud_run_service.api.location
role = "roles/run.invoker"
member = "allUsers"
}
resource "google_sql_database_instance" "main" {
name = "main-instance"
database_version = "POSTGRES_14"
region = "us-central1"
settings {
tier = "db-f1-micro"
backup_configuration {
enabled = true
start_time = "03:00"
}
ip_configuration {
ipv4_enabled = false
private_network = google_compute_network.vpc.id
}
database_flags {
name = "max_connections"
value = "100"
}
}
deletion_protection = true
}
resource "google_storage_bucket" "frontend" {
name = "my-app-frontend"
location = "US"
force_destroy = false
uniform_bucket_level_access = true
website {
main_page_suffix = "index.html"
not_found_page = "404.html"
}
cors {
origin = ["https://example.com"]
method = ["GET", "HEAD"]
response_header = ["*"]
max_age_seconds = 3600
}
}
resource "google_compute_backend_bucket" "cdn" {
name = "cdn-backend"
bucket_name = google_storage_bucket.frontend.name
enable_cdn = true
cdn_policy {
cache_mode = "CACHE_ALL_STATIC"
client_ttl = 3600
default_ttl = 3600
max_ttl = 86400
negative_caching = true
serve_while_stale = 86400
}
}
Architecture:
┌──────────────────────────────────────────┐
│ Cloud Load Balancer (Ingress) │
└────────────┬─────────────────────────────┘
│
┌────────────▼─────────────────────────────┐
│ GKE Cluster │
│ ┌──────────┐ ┌──────────┐ │
│ │Service A │ │Service B │ │
│ └──────────┘ └──────────┘ │
└────────────┬─────────────────────────────┘
│
┌────────────▼─────────────────────────────┐
│ Cloud SQL + Memorystore │
└──────────────────────────────────────────┘
Kubernetes Manifests:
```yaml
# deployment.yaml
apiVersion: apps/v1