30 lines
839 B
Bash
30 lines
839 B
Bash
#!/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 you’ve 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"
|