feat(scripts): prepare-app.sh — build images, create PV
This commit is contained in:
parent
bd9fafe937
commit
24d9502705
47
prepare-app.sh
Normal file
47
prepare-app.sh
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "[prepare-app] Preparing Task Manager for Kubernetes..."
|
||||||
|
|
||||||
|
# 1. Ensure minikube is running
|
||||||
|
if ! minikube status >/dev/null 2>&1; then
|
||||||
|
echo "[prepare-app] minikube is not running. Starting it..."
|
||||||
|
minikube start
|
||||||
|
else
|
||||||
|
echo "[prepare-app] minikube is already running."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Point local docker at minikube's daemon so images land inside the cluster
|
||||||
|
echo "[prepare-app] Switching docker context to minikube..."
|
||||||
|
eval "$(minikube -p minikube docker-env)"
|
||||||
|
|
||||||
|
# 3. Build the two custom images
|
||||||
|
echo "[prepare-app] Building taskapp-api:v1..."
|
||||||
|
docker build -t taskapp-api:v1 backend/
|
||||||
|
|
||||||
|
echo "[prepare-app] Building taskapp-web:v1..."
|
||||||
|
docker build -t taskapp-web:v1 frontend/
|
||||||
|
|
||||||
|
# 4. Create the hostPath directory on the minikube node
|
||||||
|
echo "[prepare-app] Creating /mnt/data/taskapp-db on the minikube node..."
|
||||||
|
minikube ssh -- "sudo mkdir -p /mnt/data/taskapp-db && sudo chmod 777 /mnt/data/taskapp-db"
|
||||||
|
|
||||||
|
# 5. Apply the namespace (so the PVC has a place to live) and the StatefulSet stack.
|
||||||
|
# The namespace must exist before namespaced objects (PVC, StatefulSet) can be created,
|
||||||
|
# so we apply and then poll for it to exist before continuing.
|
||||||
|
echo "[prepare-app] Creating Namespace, Secret, ConfigMap..."
|
||||||
|
kubectl apply -f namespace.yaml
|
||||||
|
|
||||||
|
echo "[prepare-app] Waiting for taskapp namespace to be available..."
|
||||||
|
for _ in $(seq 1 20); do
|
||||||
|
if kubectl get namespace taskapp >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[prepare-app] Creating PV, PVC, StatefulSet..."
|
||||||
|
kubectl apply -f statefulset.yaml
|
||||||
|
|
||||||
|
echo "[prepare-app] App prepared."
|
||||||
|
echo "[prepare-app] Run ./start-app.sh to bring up the rest."
|
||||||
Loading…
Reference in New Issue
Block a user