Local Deployment Guide (Kind + Tilt)
This guide details how to deploy the Ride Sharing application locally using Kind (Kubernetes in Docker) and Tilt. This setup mirrors the production Kubernetes environment while offering a fast inner development loop.
Prerequisites
Ensure you have the following installed on your machine:
- Docker: Container runtime.
- Go: Programming language (v1.22+).
- Kind: Tool for running local Kubernetes clusters.
- Tilt: Tool for microservices development.
- Kubectl: Kubernetes command-line tool.
Initial Setup
-
Create a Kind Cluster:
kind create cluster --name ride-sharing -
Point Kubectl to Kind:
kubectl cluster-info --context kind-ride-sharing
Disk Space Management (Critical)
Running a full microservices stack locally consumes significant disk space. If you encounter no space left on device errors during image builds or loads:
-
Prune Docker System:
docker system prune -a -f --volumesWarning: This deletes all stopped containers, unused networks, and dangling images.
-
Clean Dependencies Caches:
go clean -cache
go clean -modcache
rm -rf web/node_modules web/.next
kind delete cluster --name ride-sharing
docker volume prune
Deployment with Tilt
Tilt manages the entire lifecycle: building Docker images, loading them into Kind, and deploying Kubernetes manifests.
-
Start Tilt:
tilt up -
Access the Dashboard: Open http://localhost:10355 to monitor services and logs in real-time.
Accessing Services
Once all services are up (green in Tilt), you can access them at these addresses:
| Service | URL | Description |
|---|---|---|
| Frontend App | http://localhost:3000 | The main Ride Sharing interface |
| Tilt Dashboard | http://localhost:10355 | Build logs, status, and control |
| Jaeger UI | http://localhost:16686 | Distributed tracing viewer |
| RabbitMQ Manager | http://localhost:15672 | Queue monitoring (User: guest/guest) |
| API Gateway | http://localhost:8081 | Direct API access (for debugging) |
Database persistence
- Docker Compose:
mongodb_dataandpostgres_dataare named volumes. Stopping containers or rebuilding app images does not remove them; onlydocker compose down -v(ordocker volume rm) clears data. - Kind + Tilt: MongoDB is backed by the
mongodb-pvcPersistentVolumeClaim (seeinfra/development/k8s/mongodb-pvc.yaml) mounted at/data/db. Replacing the Deployment or upgrading the image keeps data as long as you do not delete the PVC. - Production: Use your cloud provider’s managed PostgreSQL and MongoDB (or compatible URI). Set
DATABASE_URLfor platform-service andMONGODB_URIfor trip-service / driver-service to those connection strings. Application redeploys then only restart processes; the databases retain all records.
Offline / Restricted Network Mode
If you are working in an environment with restricted internet access (e.g., VPNs, corporate firewalls) where Docker containers cannot reach external APIs:
1. OSRM (Routing) Fallback
The trip-service attempts to reach http://router.project-osrm.org. If this times out:
- Open
services/trip-service/internal/infrastructure/grpc/grpc_handler.go. - Locate the
PreviewTripfunction. - Change the
GetRoutecall's last argument tofalse:// false = disable external OSRM API and use local mock calculation
route, err := h.service.GetRoute(ctx, pickupCoord, destinationCoord, false)
2. Stripe (Payment) Fallback
The payment-service attempts to reach Stripe APIs. If this fails:
- The code includes a fallback to return a mock session ID if the Stripe API call returns an error.
- You will see a log:
Error creating Stripe session... Returning MOCK session.
Troubleshooting Common Issues
"CrashLoopBackOff" on Startup
- Cause: Usually missing environment variables or DB connectivity.
- Fix: Check
infra/development/k8s/secrets.yaml. EnsureMONGODB_URIaligns with the local service (mongodb://mongodb:27017/ride-sharing).
"ImagePullBackOff" or "ErrImageNeverPull"
- Cause: Tilt failed to load the image into Kind, or Kind cannot pull a public image.
- Fix:
- Check disk space (see above).
- Manually pull/load:
docker pull mongo:5.0
kind load docker-image mongo:5.0 --name ride-sharing
Frontend Not Updating
- Cause: Next.js cache or build failure.
- Fix: Trigger a rebuild in the Tilt UI, or delete
web/.nextlocally and restart Tilt.
useful Commands
- View Pods:
kubectl get pods - View Logs:
kubectl logs -f deployment/<service-name> - Restart Service:
kubectl rollout restart deployment/<service-name>
killall tilt