-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-local.sh
More file actions
61 lines (52 loc) · 2.24 KB
/
setup-local.sh
File metadata and controls
61 lines (52 loc) · 2.24 KB
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
#!/usr/bin/env bash
set -euo pipefail
CLUSTER_NAME="fraud-detection"
NAMESPACE="fraud-detection"
echo "[1/7] Creating Kind cluster with port mappings..."
if kind get clusters | grep -q "^${CLUSTER_NAME}$"; then
echo " Cluster '${CLUSTER_NAME}' already exists, skipping creation"
else
kind create cluster --name "${CLUSTER_NAME}" --config kind-config.yaml
fi
echo "[2/7] Building Docker images..."
docker compose build
echo "[3/7] Loading custom images into Kind..."
SERVICES="transaction-simulator feature-enrichment ml-scorer decision-engine shap-explainer api-gateway dashboard"
for svc in $SERVICES; do
IMAGE="fraud-detection/${svc}:latest"
echo " Loading ${IMAGE}..."
kind load docker-image "${IMAGE}" --name "${CLUSTER_NAME}"
done
echo "[4/7] Deploying ingress-nginx..."
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
kubectl wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=120s
echo "[5/7] Deploying metrics-server and patching for Kind..."
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl patch deployment metrics-server -n kube-system \
--type='json' \
-p='[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'
echo "[6/7] Applying Kubernetes manifests..."
kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/secrets/
kubectl apply -f k8s/configmaps/
kubectl apply -f k8s/statefulsets/
kubectl apply -f k8s/services/internal/
kubectl apply -f k8s/services/external/
kubectl apply -f k8s/deployments/
kubectl apply -f k8s/hpa/
kubectl apply -f k8s/pdb/
kubectl apply -f k8s/networkpolicy/
kubectl apply -f k8s/ingress/
kubectl apply -f k8s/cronjob/
kubectl apply -f k8s/monitoring/ 2>/dev/null || echo " (monitoring stack not yet deployed)"
echo "[7/7] Waiting for all pods to be ready..."
kubectl wait --for=condition=ready pod --all -n "${NAMESPACE}" --timeout=300s
echo ""
echo "Setup complete!"
echo " Dashboard: http://localhost"
echo " API: http://localhost/api/health"
echo " Grafana: http://localhost:3000 (admin/admin)"
echo " Prometheus: http://localhost:9090"