|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | 3 |
|
4 | | -echo "Installing Nginx Ingress Controller..." |
| 4 | +echo "========================================" |
| 5 | +echo "Hankers Infrastructure Setup" |
| 6 | +echo "========================================" |
| 7 | +echo "" |
5 | 8 |
|
6 | | -# Apply the official nginx ingress controller manifest |
| 9 | +# ============================================ |
| 10 | +# 1. Install Nginx Ingress Controller |
| 11 | +# ============================================ |
| 12 | +echo "[1/5] Installing Nginx Ingress Controller..." |
7 | 13 | kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.11.2/deploy/static/provider/cloud/deploy.yaml |
8 | 14 |
|
9 | | -echo "" |
10 | 15 | echo "Waiting for controller to be ready..." |
11 | 16 | kubectl wait --namespace ingress-nginx \ |
12 | 17 | --for=condition=ready pod \ |
13 | 18 | --selector=app.kubernetes.io/component=controller \ |
14 | 19 | --timeout=120s |
15 | 20 |
|
| 21 | +echo "✅ Nginx Ingress Controller installed!" |
| 22 | +echo "" |
| 23 | + |
| 24 | +# ============================================ |
| 25 | +# 2. Install Cert-Manager |
| 26 | +# ============================================ |
| 27 | +echo "[2/5] Installing Cert-Manager..." |
| 28 | +kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.2/cert-manager.yaml |
| 29 | + |
| 30 | +echo "Waiting for cert-manager to be ready..." |
| 31 | +kubectl wait --namespace cert-manager \ |
| 32 | + --for=condition=ready pod \ |
| 33 | + --selector=app.kubernetes.io/instance=cert-manager \ |
| 34 | + --timeout=120s |
| 35 | + |
| 36 | +echo "✅ Cert-Manager installed!" |
| 37 | +echo "" |
| 38 | + |
| 39 | +# ============================================ |
| 40 | +# 3. Create Let's Encrypt ClusterIssuer |
| 41 | +# ============================================ |
| 42 | +echo "[3/5] Creating Let's Encrypt ClusterIssuer..." |
| 43 | +kubectl apply -f setup/letsencrypt-issuer.yaml |
| 44 | + |
| 45 | +echo "✅ Let's Encrypt ClusterIssuer created!" |
16 | 46 | echo "" |
17 | | -echo "✅ Nginx Ingress Controller installed successfully!" |
| 47 | + |
| 48 | +# ============================================ |
| 49 | +# 4. Configure TCP Services for Redis |
| 50 | +# ============================================ |
| 51 | +echo "[4/5] Configuring TCP Services for Redis..." |
| 52 | +kubectl apply -f setup/tcp-services.yaml |
| 53 | + |
| 54 | +echo "✅ TCP Services ConfigMap created!" |
| 55 | +echo "" |
| 56 | + |
| 57 | +# ============================================ |
| 58 | +# 5. Patch Ingress Controller for TCP |
| 59 | +# ============================================ |
| 60 | +echo "[5/5] Patching Ingress Controller..." |
| 61 | + |
| 62 | +# Add TCP services argument if not already present |
| 63 | +if ! kubectl get deployment ingress-nginx-controller -n ingress-nginx -o yaml | grep -q "tcp-services-configmap"; then |
| 64 | + echo "Adding TCP services configuration..." |
| 65 | + kubectl patch deployment ingress-nginx-controller -n ingress-nginx --type='json' -p='[ |
| 66 | + {"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--tcp-services-configmap=ingress-nginx/tcp-services"} |
| 67 | + ]' |
| 68 | +else |
| 69 | + echo "TCP services already configured" |
| 70 | +fi |
| 71 | + |
| 72 | +# Add port 6379 to ingress controller service if not already present |
| 73 | +if ! kubectl get svc ingress-nginx-controller -n ingress-nginx -o yaml | grep -q "port: 6379"; then |
| 74 | + echo "Adding Redis port to ingress controller..." |
| 75 | + kubectl patch svc ingress-nginx-controller -n ingress-nginx --type='json' -p='[ |
| 76 | + {"op": "add", "path": "/spec/ports/-", "value": {"name": "redis", "port": 6379, "protocol": "TCP", "targetPort": 6379}} |
| 77 | + ]' |
| 78 | +else |
| 79 | + echo "Redis port already configured" |
| 80 | +fi |
| 81 | + |
| 82 | +echo "✅ Ingress Controller patched!" |
18 | 83 | echo "" |
19 | | -echo "Getting external IP..." |
20 | | -kubectl get svc ingress-nginx-controller -n ingress-nginx |
21 | 84 |
|
| 85 | +# ============================================ |
| 86 | +# Summary |
| 87 | +# ============================================ |
| 88 | +echo "========================================" |
| 89 | +echo "✅ Infrastructure Setup Complete!" |
| 90 | +echo "========================================" |
| 91 | +echo "" |
| 92 | +echo "Ingress Controller External IP:" |
| 93 | +kubectl get svc ingress-nginx-controller -n ingress-nginx | grep ingress-nginx-controller |
| 94 | +echo "" |
| 95 | +echo "Next steps:" |
| 96 | +echo "1. Update your DNS records to point to the external IP above" |
| 97 | +echo "2. Deploy your backend: helm install/upgrade hankers-backend-dev" |
| 98 | +echo "3. Deploy your frontend: helm install/upgrade hankers-frontend-dev" |
| 99 | +echo "4. Deploy Redis if not already deployed" |
22 | 100 | echo "" |
23 | 101 | echo "To watch for IP assignment:" |
24 | 102 | echo "kubectl get svc ingress-nginx-controller -n ingress-nginx -w" |
0 commit comments