Add Flux GitOps bootstrap for minikube
Set up a complete GitOps pipeline using Flux CD to manage a minikube cluster. Includes bootstrap script, Traefik ingress controller via HelmRelease, and a hello-world nginx deployment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
bootstrap.sh
Executable file
57
bootstrap.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "=== Step 1: Ensuring minikube is running ==="
|
||||
if minikube status --format='{{.Host}}' 2>/dev/null | grep -q "Running"; then
|
||||
echo "minikube is already running."
|
||||
else
|
||||
echo "Starting minikube..."
|
||||
minikube start --driver=docker
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Step 2: Checking Flux prerequisites ==="
|
||||
flux check --pre
|
||||
|
||||
echo ""
|
||||
echo "=== Step 3: Installing Flux controllers ==="
|
||||
flux install
|
||||
|
||||
echo ""
|
||||
echo "=== Step 4: Applying GitRepository and root Kustomization ==="
|
||||
kubectl apply -f "${SCRIPT_DIR}/clusters/minikube/flux-system/gotk-sync.yaml"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 5: Triggering reconciliation and waiting ==="
|
||||
sleep 5
|
||||
flux reconcile source git flux-system
|
||||
sleep 5
|
||||
flux reconcile kustomization flux-system
|
||||
|
||||
echo "Waiting for infrastructure kustomization to become ready..."
|
||||
kubectl wait --for=condition=Ready kustomization/infrastructure \
|
||||
-n flux-system --timeout=300s || true
|
||||
|
||||
echo "Waiting for apps kustomization to become ready..."
|
||||
kubectl wait --for=condition=Ready kustomization/apps \
|
||||
-n flux-system --timeout=300s || true
|
||||
|
||||
echo ""
|
||||
echo "=== Step 6: Final status ==="
|
||||
echo "--- Flux resources ---"
|
||||
flux get all
|
||||
|
||||
echo ""
|
||||
echo "--- All pods ---"
|
||||
kubectl get pods -A
|
||||
|
||||
echo ""
|
||||
echo "--- Services ---"
|
||||
kubectl get svc -A
|
||||
|
||||
echo ""
|
||||
echo "Bootstrap complete."
|
||||
echo "To access nginx-hello: kubectl port-forward -n nginx-hello svc/nginx-hello 8080:80"
|
||||
echo "To access Traefik dashboard: minikube service traefik-dashboard -n traefik --url (if enabled)"
|
||||
Reference in New Issue
Block a user