#!/bin/bash set -e set -o pipefail # Ensure WILD_INSTANCE is set if [ -z "${WILD_INSTANCE}" ]; then echo "❌ ERROR: WILD_INSTANCE is not set" exit 1 fi # Ensure WILD_API_DATA_DIR is set if [ -z "${WILD_API_DATA_DIR}" ]; then echo "❌ ERROR: WILD_API_DATA_DIR is not set" exit 1 fi # Ensure KUBECONFIG is set if [ -z "${KUBECONFIG}" ]; then echo "❌ ERROR: KUBECONFIG is not set" exit 1 fi INSTANCE_DIR="${WILD_API_DATA_DIR}/instances/${WILD_INSTANCE}" SNAPSHOT_CONTROLLER_DIR="${INSTANCE_DIR}/apps/snapshot-controller" echo "🔧 === Setting up Snapshot Controller ===" echo "" # Templates should already be compiled echo "📦 Using pre-compiled snapshot-controller templates..." if [ ! -f "${SNAPSHOT_CONTROLLER_DIR}/kustomization.yaml" ]; then echo "❌ ERROR: Compiled templates not found at ${SNAPSHOT_CONTROLLER_DIR}/kustomization.yaml" echo "Templates should be compiled before deployment." exit 1 fi echo "🚀 Deploying Snapshot Controller..." kubectl apply -k ${SNAPSHOT_CONTROLLER_DIR}/ echo "⏳ Waiting for snapshot-controller to be ready..." kubectl wait --for=condition=available --timeout=300s deployment/snapshot-controller -n kube-system || true # Check if VolumeSnapshot CRDs are installed echo "✔️ Checking VolumeSnapshot CRDs..." kubectl api-resources | grep -q "snapshot.storage.k8s.io" && echo "✅ VolumeSnapshot CRDs found" || echo "⚠️ VolumeSnapshot CRDs not found" echo "" echo "✅ Snapshot Controller installed successfully" echo "" echo "💡 To verify the installation:" echo " kubectl get pods -n kube-system | grep snapshot-controller" echo " kubectl get crd | grep snapshot" echo "" echo "📘 To create a snapshot:" echo " kubectl apply -f - <