Skip to main content

GCP GKE Deployment Guide

This guide provides step-by-step instructions to deploy the Ride Sharing application to Google Kubernetes Engine (GKE).

Prerequisites

  • Google Cloud Platform (GCP) Account
  • gcloud CLI installed and authenticated
  • kubectl CLI installed
  • Docker installed

1. Environment Setup

Set your project variables for easy copy-pasting:

export PROJECT_ID=<your-gcp-project-id>
export REGION=europe-west1 # or your preferred region

Login to Google Cloud:

gcloud auth login
gcloud config set project $PROJECT_ID

2. Infrastructure & Secrets

2.1 Edit Secrets

Open infra/production/k8s/secrets.yaml and replace the placeholder values:

  • <RABBITMQ_URI>: URI for your RabbitMQ instance (e.g., from CloudAMQP or self-hosted)
  • <MONGODB_URI>: URI for your MongoDB (e.g., from MongoDB Atlas)
  • <STRIPE_SECRET_KEY>: Your Stripe Secret Key
  • <STRIPE_WEBHOOK_KEY>: Your Stripe Webhook Key

Note: The OSRM URL is pre-configured to http://router.project-osrm.org/route/v1.

3. Build and Push Docker Images

Authenticate Docker with GCP Artifact Registry:

gcloud auth configure-docker ${REGION}-docker.pkg.dev

Create the Artifact Registry repository (if not exists):

gcloud artifacts repositories create ride-sharing \
--repository-format=docker \
--location=$REGION \
--description="Docker repository for Ride Sharing"

Build and Push images:

API Gateway

docker build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/api-gateway:latest --platform linux/amd64 -f infra/production/docker/api-gateway.Dockerfile .
docker push ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/api-gateway:latest

Driver Service

docker build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/driver-service:latest --platform linux/amd64 -f infra/production/docker/driver-service.Dockerfile .
docker push ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/driver-service:latest

Trip Service

docker build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/trip-service:latest --platform linux/amd64 -f infra/production/docker/trip-service.Dockerfile .
docker push ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/trip-service:latest

Payment Service

docker build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/payment-service:latest --platform linux/amd64 -f infra/production/docker/payment-service.Dockerfile .
docker push ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/payment-service:latest

Platform Service (finance ledger gRPC + user auth gRPC + RabbitMQ payment + audit consumers; PostgreSQL + same RABBITMQ_URI as payment)

docker build -t ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/platform-service:latest --platform linux/amd64 -f infra/production/docker/platform-service.Dockerfile .
docker push ${REGION}-docker.pkg.dev/${PROJECT_ID}/ride-sharing/platform-service:latest

Production Kubernetes manifests under infra/production/k8s/ do not yet include a Deployment for platform-service; after pushing this image, add a workload and set PLATFORM_SERVICE_URL on the API gateway (or legacy FINANCE_SERVICE_URL / USER_AUTH_SERVICE_URL). See Finance & RBAC for ports and environment variables.

4. Deploy to GKE

Create a GKE Cluster (if not exists):

gcloud container clusters create ride-sharing-cluster \
--zone $REGION-b \
--num-nodes 3

Get credentials for kubectl:

gcloud container clusters get-credentials ride-sharing-cluster --zone $REGION-b

Apply Manifests:

# 1. Configs and Secrets
kubectl apply -f infra/production/k8s/app-config.yaml
kubectl apply -f infra/production/k8s/secrets.yaml

# 2. Infrastructure Services (RabbitMQ, Jaeger)
# Note: Skip RabbitMQ if using managed service
kubectl apply -f infra/production/k8s/jaeger-deployment.yaml
kubectl apply -f infra/production/k8s/rabbitmq-deployment.yaml

# 3. Microservices
kubectl apply -f infra/production/k8s/api-gateway-deployment.yaml
kubectl apply -f infra/production/k8s/driver-service-deployment.yaml
kubectl apply -f infra/production/k8s/trip-service-deployment.yaml
kubectl apply -f infra/production/k8s/payment-service-deployment.yaml

5. Verify Deployment

Check the status of your pods:

kubectl get pods

Get the External IP of the API Gateway:

kubectl get svc api-gateway

6. Frontend Deployment (Vercel)

The repository root has no app package.json by default—the Next.js app is under web/. If Vercel is connected to the whole repo and you see ENOENT ... package.json at /vercel/path0, use either:

  1. Recommended: In the Vercel project, open Settings → General → Root Directory and set it to web, then redeploy; or
  2. Rely on the root package.json in this repo: it runs npm install at the root (no deps) and npm run build, which runs npm ci and next build under web/.

Set environment variables in the Vercel dashboard (see web/.env.local for local names):

  • NEXT_PUBLIC_API_URL: http://<EXTERNAL-IP-OF-API-GATEWAY>:8081
  • NEXT_PUBLIC_WEBSOCKET_URL: ws://<EXTERNAL-IP-OF-API-GATEWAY>:8081/ws
  • NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: Your Stripe Public Key

Kubernetes Ecosystem & Resources