#!/bin/bash set -e echo "=== Starting Kubernetes Application Deployment ===" echo "[1/4] Creating Namespace..." kubectl apply -f namespace.yaml echo "[2/4] Generating ConfigMap for the MySQL database init script..." kubectl create configmap mysql-initdb-config --namespace=smartbuilding-namespace --from-file=webapp/user.sql --dry-run=client -o yaml | kubectl apply -f - echo "[3/4] Applying StatefulSet, PV, PVC, and Headless Service..." kubectl apply -f statefulset.yaml echo "[4/4] Applying Node.js Deployment and public Service..." kubectl apply -f deployment.yaml kubectl apply -f service.yaml echo "" echo "=== Initialization Complete! ===" echo "Note: The database container may take a minute to initialize." echo "You can check the status of your pods by running:" echo " kubectl get pods -n smartbuilding-namespace -w" echo "" echo "To access the web application in Minikube, open a new terminal and run:" echo " minikube service webapp-service -n smartbuilding-namespace"