|
47 | 47 | # Stop any existing LocalStack containers |
48 | 48 | docker stop localstack-k3d 2>/dev/null || true |
49 | 49 | docker rm localstack-k3d 2>/dev/null || true |
50 | | - # Start LocalStack with port exposed, listening on all interfaces |
| 50 | + # Start LocalStack using host network mode so it's directly accessible |
| 51 | + # This ensures it's accessible from k3d pods via host.k3d.internal |
51 | 52 | docker run -d --name localstack-k3d \ |
52 | | - -p 0.0.0.0:4566:4566 \ |
| 53 | + --network host \ |
53 | 54 | -e SERVICES=s3,cloudformation,ecs,kinesis,cloudwatch,logs \ |
54 | 55 | -e DEBUG=1 \ |
55 | 56 | -e DOCKER_HOST=unix:///var/run/docker.sock \ |
|
67 | 68 | done |
68 | 69 | # Verify LocalStack is accessible |
69 | 70 | curl -s http://localhost:4566/_localstack/health | head -5 || echo "LocalStack health check" |
| 71 | + # Show network info |
| 72 | + echo "LocalStack container network info:" |
| 73 | + docker inspect localstack-k3d | grep -i network -A 5 || true |
70 | 74 | - name: Install awscli-local |
71 | 75 | run: | |
72 | 76 | pip install awscli-local || pip3 install awscli-local || echo "awslocal installation skipped" |
@@ -96,11 +100,23 @@ jobs: |
96 | 100 | kubectl get storageclass |
97 | 101 | # Show node resources |
98 | 102 | kubectl describe nodes | grep -A 5 "Allocated resources" || true |
99 | | - # Test LocalStack connectivity from cluster |
100 | | - echo "Testing LocalStack connectivity from k3d cluster via host.k3d.internal:4566..." |
101 | | - kubectl run test-localstack --image=curlimages/curl --rm -i --restart=Never --timeout=10s -- \ |
102 | | - curl -s --max-time 5 http://host.k3d.internal:4566/_localstack/health 2>&1 | head -10 || \ |
103 | | - echo "Note: If this fails, LocalStack may need additional network configuration" |
| 103 | + # Get host gateway IP that k3d uses |
| 104 | + HOST_IP=$(docker inspect k3d-unity-builder-agent-0 | grep -i gateway | head -1 | grep -oE '"Gateway":"[^"]*"' | cut -d'"' -f4 || echo "") |
| 105 | + if [ -z "$HOST_IP" ]; then |
| 106 | + # Try alternative method |
| 107 | + HOST_IP=$(docker network inspect k3d-unity-builder | grep -i gateway | head -1 | grep -oE '"Gateway":"[^"]*"' | cut -d'"' -f4 || echo "") |
| 108 | + fi |
| 109 | + echo "Host gateway IP: $HOST_IP" |
| 110 | + echo "Testing LocalStack from host (should work):" |
| 111 | + curl -s --max-time 5 http://localhost:4566/_localstack/health | head -5 || echo "Host connectivity failed" |
| 112 | + echo "Testing LocalStack from k3d cluster via host.k3d.internal:4566..." |
| 113 | + kubectl run test-localstack-dns --image=curlimages/curl --rm -i --restart=Never --timeout=10s -- \ |
| 114 | + curl -v --max-time 5 http://host.k3d.internal:4566/_localstack/health 2>&1 | head -15 || echo "DNS-based connectivity test completed" |
| 115 | + if [ -n "$HOST_IP" ]; then |
| 116 | + echo "Testing LocalStack from k3d cluster via host IP $HOST_IP:4566..." |
| 117 | + kubectl run test-localstack-ip --image=curlimages/curl --rm -i --restart=Never --timeout=10s -- \ |
| 118 | + curl -v --max-time 5 http://$HOST_IP:4566/_localstack/health 2>&1 | head -15 || echo "IP-based connectivity test completed" |
| 119 | + fi |
104 | 120 | - uses: actions/setup-node@v4 |
105 | 121 | with: |
106 | 122 | node-version: 20 |
|
0 commit comments