Spaces:
Running
on
Zero
Running
on
Zero
File size: 2,709 Bytes
0ccf2f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
#!/bin/bash
# Demo: Build Docker image and deploy to Docker Desktop Kubernetes
set -e
echo "π³π§ Docker Desktop + Kubernetes Demo for Warbler CDA"
echo "======================================================"
echo ""
# Check Docker is running
if ! docker info &> /dev/null; then
echo "β Docker is not running. Please start Docker Desktop first."
exit 1
fi
# Check if kubectl is available and connected to Docker Desktop Kubernetes
if ! kubectl cluster-info &> /dev/null; then
echo "β kubectl is not connected to Kubernetes cluster."
echo " Please enable Kubernetes in Docker Desktop (Settings β Kubernetes β Enable Kubernetes)"
exit 1
fi
echo "β
Docker and Kubernetes are running!"
# Step 1: Build the Docker image
echo ""
echo "π¨ Step 1: Building Docker image (with full dependencies for API service)..."
# Handle directory navigation smartly
ORIGINAL_DIR=$(pwd)
PROJECT_DIR="$ORIGINAL_DIR"
if [[ "$ORIGINAL_DIR" == *"/k8s" ]]; then
PROJECT_DIR="${ORIGINAL_DIR%/k8s}"
fi
echo " Building from directory: $PROJECT_DIR"
cd "$PROJECT_DIR"
docker build -t warbler-cda:latest .
cd "$ORIGINAL_DIR"
echo "β
Image built successfully!"
# Step 2: Deploy to Kubernetes
echo ""
echo "π Step 2: Deploying to Kubernetes..."
# Debug: Check if deploy.sh exists and is executable
if [[ ! -f "deploy.sh" ]] || [[ ! -x "deploy.sh" ]]; then
echo "β deploy.sh not found or not executable"
exit 1
fi
echo " Running deploy.sh..."
if ! ./deploy.sh; then
echo "β Deployment failed! Checking logs..."
echo ""
echo "π Recent events in default namespace:"
kubectl get events --sort-by=.metadata.creationTimestamp | tail -10
echo ""
echo "π Check pod status if deployment partially succeeded:"
kubectl get pods -n warbler-cda 2>/dev/null || echo " Namespace not yet created"
# Don't exit - let user troubleshoot
echo ""
echo "β οΈ Deployment had issues but continuing with troubleshooting steps..."
fi
# Step 3: Wait for deployment and show access info
echo ""
echo "β³ Step 3: Setting up port forwarding..."
echo " (This will make your app accessible at http://localhost:8001)"
echo ""
echo " In a new terminal, run:"
echo " kubectl port-forward svc/warbler-cda-service 8001:80 -n warbler-cda"
echo ""
echo " Then visit: http://localhost:8001/health"
echo ""
echo "π Current status:"
kubectl get pods -n warbler-cda
kubectl get svc -n warbler-cda
echo ""
echo "π View logs:"
echo " kubectl logs -f deployment/warbler-cda -n warbler-cda"
echo ""
echo "π§Ή Cleanup when done:"
echo " kubectl delete -f k8s/"
echo ""
echo "π Demo complete! Your Warbler CDA is now running on Kubernetes!"
|