|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Build Docker images for Kubernetes deployment |
| 4 | +echo "🏗️ Building Docker images for Kubernetes..." |
| 5 | + |
| 6 | +# Build API service image |
| 7 | +echo "Building API service image..." |
| 8 | +docker build -t dealership-api:latest ./server/database/ |
| 9 | + |
| 10 | +# Build Django service image |
| 11 | +echo "Building Django service image..." |
| 12 | +docker build -t dealership-django:latest ./server/ |
| 13 | + |
| 14 | +echo "✅ Docker images built successfully!" |
| 15 | + |
| 16 | +# Apply Kubernetes configurations |
| 17 | +echo "🚀 Deploying to Kubernetes..." |
| 18 | + |
| 19 | +# Apply configurations in order |
| 20 | +kubectl apply -f k8s/configmap.yaml |
| 21 | +kubectl apply -f k8s/mongodb.yaml |
| 22 | +kubectl apply -f k8s/api-service.yaml |
| 23 | +kubectl apply -f k8s/django-service.yaml |
| 24 | + |
| 25 | +echo "⏳ Waiting for deployments to be ready..." |
| 26 | + |
| 27 | +# Wait for deployments |
| 28 | +kubectl wait --for=condition=available --timeout=300s deployment/mongodb |
| 29 | +kubectl wait --for=condition=available --timeout=300s deployment/dealership-api |
| 30 | +kubectl wait --for=condition=available --timeout=300s deployment/dealership-django |
| 31 | + |
| 32 | +echo "✅ Kubernetes deployment complete!" |
| 33 | + |
| 34 | +# Show status |
| 35 | +echo "📊 Deployment Status:" |
| 36 | +kubectl get pods |
| 37 | +echo "" |
| 38 | +kubectl get services |
| 39 | + |
| 40 | +echo "" |
| 41 | +echo "🌐 Access your application:" |
| 42 | +echo "Django App: kubectl port-forward service/dealership-django-service 8000:8000" |
| 43 | +echo "API Service: kubectl port-forward service/dealership-api-service 3030:3030" |
0 commit comments