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!"