Files
homelab/terraform/scripts/phase-0-reconciliation.sh
T
Story Crater BotandClaude Haiku 4.5 f2b6ad1c60 feat(terraform): import Longhorn StorageClasses and app PVCs to Terraform state
- Phase 1: longhorn, longhorn-kafka StorageClasses (cluster-wide defaults)
- Phase 2 pilot: grafana, loki, portainer, forgejo PVCs
- All imports protected by lifecycle.prevent_destroy
- Removes Helm annotations (meta.helm.sh/*) to prevent dual-ownership conflicts
- Remote state backend (MinIO S3) syncs automatically on plan/apply
- Import-only approach: zero data loss, existing volumes untouched
- See terraform/LONGHORN_PVC_IMPORT.md for execution record

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
2026-08-18 15:08:01 -07:00

57 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Phase 0 — Read-only reconciliation of three ownership ambiguities
# Safe to run; only queries, no mutations
set -e
cd "$(dirname "$0")/.."
echo "=== Phase 0: Cluster Reconciliation ==="
echo ""
# Ambiguity 1: minio (storage) — standalone chart vs. Operator Tenant
echo "--- Ambiguity 1: minio (storage) ownership ---"
echo "Helm releases in 'storage' namespace:"
helm list -n storage || echo " (helm list failed)"
echo ""
echo "MinIO Operator Tenants in 'storage' namespace:"
kubectl get tenant -n storage -o wide 2>/dev/null || echo " (no Tenant CRD or none found)"
echo ""
echo "PVCs in 'storage' namespace:"
kubectl get pvc -n storage -o wide || echo " (kubectl failed)"
echo ""
# Ambiguity 2: kmsvc-redis — helmfile release vs. ArgoCD Application
echo "--- Ambiguity 2: kmsvc-redis ownership ---"
echo "ArgoCD Applications containing 'redis':"
argocd app list | grep redis || echo " (no match or argocd unavailable)"
echo ""
echo "Helm releases in 'sqs' namespace:"
helm list -n sqs | grep redis || echo " (no redis release)"
echo ""
echo "Redis-related PVCs in 'sqs' namespace:"
kubectl get pvc -n sqs -o wide | grep -i redis || echo " (no redis PVC)"
echo ""
# Ambiguity 3: forgejo-runner — helm chart vs. raw manifest
echo "--- Ambiguity 3: forgejo-runner ownership ---"
echo "Helm releases in 'cicd' namespace containing 'runner':"
helm list -n cicd | grep runner || echo " (no runner release)"
echo ""
echo "Deployments in 'cicd' namespace with label app=forgejo-runner:"
kubectl get deploy -n cicd -l app=forgejo-runner -o wide || echo " (no matching deployment)"
echo ""
echo "Checking managedFields on any forgejo-runner Deployment (to identify controller):"
kubectl get deploy -n cicd -l app=forgejo-runner -o json 2>/dev/null | jq '.items[0].metadata.managedFields' 2>/dev/null || echo " (no deployment found)"
echo ""
echo "PVCs in 'cicd' namespace named runner-*:"
kubectl get pvc -n cicd -o wide | grep runner || echo " (no runner PVC)"
echo ""
echo "=== Phase 0 Complete ==="
echo "Review the output above. Determine which of the three ambiguities are resolved:"
echo " 1. minio(storage): Is Helm release or Tenant CR authoritative? (helm list vs kubectl get tenant)"
echo " 2. kmsvc-redis: Is helmfile or ArgoCD Application active? (argocd app list vs helm list)"
echo " 3. forgejo-runner: Is Helm chart or raw manifest applied? (helm list vs kubectl get deploy managedFields)"
echo ""
echo "Document your findings. Proceed to Phase 1 (StorageClass import) only after clarity."