---
title: "GCP Deployment"
description: "Deploy TraceRTM on Google Cloud Platform"
keywords: [gcp, google cloud, cloud run, cloud sql, deployment]
---

# GCP Deployment

Deploy TraceRTM on Google Cloud Platform (GCP).

## Architecture

### Recommended Setup

```
Cloud Load Balancer
    ↓
Cloud Run (API)
    ↓
Cloud SQL PostgreSQL (Database)
    ↓
Memorystore Redis (Cache)
```

## Cloud Run Deployment

### Build and Push Image

```bash
# Build image
docker build -t gcr.io/PROJECT_ID/tracertm:2.4.0 .

# Push to GCR
docker push gcr.io/PROJECT_ID/tracertm:2.4.0
```

### Deploy to Cloud Run

```bash
gcloud run deploy tracertm-api \
  --image gcr.io/PROJECT_ID/tracertm:2.4.0 \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated \
  --set-env-vars DATABASE_URL=...,REDIS_URL=... \
  --memory 2Gi \
  --cpu 2 \
  --min-instances 1 \
  --max-instances 10
```

### Service Configuration

```yaml
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: tracertm-api
spec:
  template:
    spec:
      containers:
      - image: gcr.io/PROJECT_ID/tracertm:2.4.0
        env:
        - name: DATABASE_URL
          valueFrom:
            secretKeyRef:
              name: tracertm-secrets
              key: database-url
        resources:
          limits:
            memory: 2Gi
            cpu: 2000m
```

## Cloud SQL

### Create PostgreSQL Instance

```bash
gcloud sql instances create tracertm-db \
  --database-version=POSTGRES_14 \
  --tier=db-f1-micro \
  --region=us-central1 \
  --root-password=YourPassword123
```

### Create Database

```bash
gcloud sql databases create tracertm \
  --instance=tracertm-db
```

### Connection

```bash
# Get connection name
gcloud sql instances describe tracertm-db --format="value(connectionName)"

# Connection string
DATABASE_URL=postgresql://postgres:password@/tracertm?host=/cloudsql/PROJECT_ID:REGION:tracertm-db
```

## Memorystore Redis

### Create Redis Instance

```bash
gcloud redis instances create tracertm-redis \
  --size=1 \
  --region=us-central1 \
  --redis-version=redis_7_0
```

### Connection

```bash
# Get Redis IP
gcloud redis instances describe tracertm-redis --region=us-central1 --format="value(host)"

REDIS_URL=redis://REDIS_IP:6379
```

## Cloud Load Balancer

### Create Load Balancer

```bash
gcloud compute backend-services create tracertm-backend \
  --global \
  --protocol HTTP \
  --health-checks tracertm-health-check

gcloud compute url-maps create tracertm-url-map \
  --default-service tracertm-backend

gcloud compute target-https-proxies create tracertm-https-proxy \
  --url-map tracertm-url-map \
  --ssl-certificates tracertm-ssl-cert
```

## Secrets Management

### Secret Manager

```bash
# Create secret
echo -n "postgresql://..." | gcloud secrets create database-url --data-file=-

# Grant access
gcloud secrets add-iam-policy-binding database-url \
  --member=serviceAccount:PROJECT_NUMBER-compute@developer.gserviceaccount.com \
  --role=roles/secretmanager.secretAccessor
```

## Monitoring

### Cloud Monitoring

- **Metrics**: Cloud Run metrics, Cloud SQL metrics
- **Logs**: Cloud Logging
- **Alerts**: Set up alerting policies

## Related Documentation

- [Cloud Platforms](./03-cloud-platforms) - Cloud overview
- [Docker Deployment](./01-docker-deployment) - Docker setup
