zkt25/z2/start-app.sh

30 lines
839 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Deploy the application to local Kubernetes
set -e
# Ensure kubectl uses the local Docker Desktop cluster
kubectl config use-context docker-desktop
NAMESPACE="my-app"
echo "Creating namespace..."
kubectl apply -f namespace.yaml
# (optional) if youve switched to emptyDir for Postgres storage, skip PVC
# echo "Creating PersistentVolumeClaim..."
# kubectl apply -f persistent-storage.yaml
echo "Deploying PostgreSQL..."
kubectl apply -f postgres-deployment.yaml
kubectl apply -f postgres-service.yaml
echo "Waiting for PostgreSQL pod(s) to be ready..."
kubectl wait --for=condition=ready pod -l app=postgres -n ${NAMESPACE} --timeout=120s
echo "Deploying web application..."
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
echo "Deployment complete. Access the app at http://localhost:30080"