From 24d950270546e0cad91797ce7fbdc4f5894ff402 Mon Sep 17 00:00:00 2001 From: Brazing Technology Date: Wed, 29 Apr 2026 11:29:47 +0530 Subject: [PATCH] =?UTF-8?q?feat(scripts):=20prepare-app.sh=20=E2=80=94=20b?= =?UTF-8?q?uild=20images,=20create=20PV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prepare-app.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 prepare-app.sh diff --git a/prepare-app.sh b/prepare-app.sh new file mode 100644 index 0000000..edb044d --- /dev/null +++ b/prepare-app.sh @@ -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."