source: k8s/deploy-local.sh@ 0427f59

Last change on this file since 0427f59 was 52fee06, checked in by Andrej <asumanovski@…>, 2 weeks ago

Complete Kubernetes manifests with ConfigMap, Secrets, StatefulSet, Ingress

  • namespace.yaml: trekr namespace
  • configmaps.yaml: backend non-secret config (DB URL, Hibernate settings)
  • postgres.yaml: StatefulSet + PVC + ClusterIP Service, init SQL from ConfigMap
  • backend.yaml: Deployment with ConfigMap + Secrets refs, ClusterIP Service
  • frontend.yaml: Deployment + ClusterIP Service
  • ingress.yaml: nginx Ingress routing trekr.local → frontend
  • deploy-local.sh: one-shot local demo script for Docker Desktop Kubernetes
  • Property mode set to 100755
File size: 2.2 KB
RevLine 
[52fee06]1#!/bin/bash
2set -e
3
4# ── Config ────────────────────────────────────────────────────────────────────
5read -p "DockerHub username: " DOCKERHUB_USERNAME
6read -p "DB password (choose any): " DB_PASSWORD
7read -p "JWT secret (min 32 chars): " JWT_SECRET
8
9SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
10
11echo ""
12echo "==> Switching to docker-desktop context..."
13kubectl config use-context docker-desktop
14
15echo "==> Applying namespace..."
16kubectl apply -f "$SCRIPT_DIR/namespace.yaml"
17
18echo "==> Creating secrets..."
19kubectl create secret generic trekr-secrets \
20 --namespace=trekr \
21 --from-literal=db-password="$DB_PASSWORD" \
22 --from-literal=jwt-secret="$JWT_SECRET" \
23 --save-config \
24 --dry-run=client -o yaml | kubectl apply -f -
25
26echo "==> Creating DB init ConfigMap from DDL..."
27kubectl create configmap trekr-db-init \
28 --namespace=trekr \
29 --from-file=01-ddl.sql="$SCRIPT_DIR/../db-scripts/ddl.sql" \
30 --save-config \
31 --dry-run=client -o yaml | kubectl apply -f -
32
33echo "==> Applying ConfigMaps..."
34kubectl apply -f "$SCRIPT_DIR/configmaps.yaml"
35
36echo "==> Applying Postgres StatefulSet..."
37kubectl apply -f "$SCRIPT_DIR/postgres.yaml"
38
39echo "==> Waiting for Postgres..."
40kubectl rollout status statefulset/postgres -n trekr --timeout=120s
41
42echo "==> Applying Backend Deployment..."
43sed "s|DOCKERHUB_USERNAME|$DOCKERHUB_USERNAME|g" "$SCRIPT_DIR/backend.yaml" | kubectl apply -f -
44
45echo "==> Applying Frontend Deployment..."
46sed "s|DOCKERHUB_USERNAME|$DOCKERHUB_USERNAME|g" "$SCRIPT_DIR/frontend.yaml" | kubectl apply -f -
47
48echo "==> Applying Ingress..."
49kubectl apply -f "$SCRIPT_DIR/ingress.yaml"
50
51echo "==> Waiting for backend rollout..."
52kubectl rollout status deployment/backend -n trekr --timeout=180s
53
54echo "==> Waiting for frontend rollout..."
55kubectl rollout status deployment/frontend -n trekr --timeout=60s
56
57echo ""
58echo "==> Adding trekr.local to /etc/hosts (needs sudo)..."
59if ! grep -q "trekr.local" /etc/hosts; then
60 echo "127.0.0.1 trekr.local" | sudo tee -a /etc/hosts
61fi
62
63echo ""
64echo "✅ Done! Open http://trekr.local in your browser."
Note: See TracBrowser for help on using the repository browser.