#!/bin/bash
set -e

echo "Starting To-Do List Application in Kubernetes"

# Apply namespace
kubectl apply -f k8s/namespace.yaml

# Apply PV, PVC, and StatefulSet
kubectl apply -f k8s/statefulset.yaml

# Apply deployment
kubectl apply -f k8s/deployment.yaml

# Apply service
kubectl apply -f k8s/service.yaml

echo "Waiting for the application to start..."
sleep 5

# Get NodePort information
NODE_PORT=$(kubectl get svc todo-web-service -n todo-app-ns-v2 -o jsonpath='{.spec.ports[0].nodePort}')
echo "The To-Do List application is available at: http://localhost:$NODE_PORT"

echo "Application started successfully!"


