Files
infrastructure/kubernetes/dev-staging/setup.sh
2026-02-09 21:51:46 -08:00

71 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Setup shared dev/staging Kubernetes clusters
set -e
echo "☸️ Setting up shared dev/staging Kubernetes clusters..."
# Check prerequisites
command -v kubectl >/dev/null 2>&1 || { echo "❌ kubectl not found"; exit 1; }
command -v helm >/dev/null 2>&1 || { echo "❌ helm not found"; exit 1; }
# Create namespaces
echo "📦 Creating namespaces..."
kubectl create namespace dev --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace staging --dry-run=client -o yaml | kubectl apply -f -
# Label namespaces
kubectl label namespace dev environment=dev --overwrite
kubectl label namespace staging environment=staging --overwrite
# Apply cluster configuration
echo "⚙️ Applying cluster configuration..."
kubectl apply -f cluster-config.yaml
# Set up resource quotas
echo "📊 Setting up resource quotas..."
# Dev namespace quota
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ResourceQuota
metadata:
name: dev-quota
namespace: dev
spec:
hard:
requests.cpu: "4"
requests.memory: 8Gi
limits.cpu: "8"
limits.memory: 16Gi
persistentvolumeclaims: "10"
services.loadbalancers: "2"
EOF
# Staging namespace quota
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ResourceQuota
metadata:
name: staging-quota
namespace: staging
spec:
hard:
requests.cpu: "8"
requests.memory: 16Gi
limits.cpu: "16"
limits.memory: 32Gi
persistentvolumeclaims: "20"
services.loadbalancers: "4"
EOF
echo "✅ Shared dev/staging clusters configured!"
echo ""
echo "📝 Namespaces created:"
echo " - dev"
echo " - staging"
echo ""
echo "📝 Resource quotas configured"
echo "📝 Cluster configuration applied"