====== Deleting Longhorn ======
===== Step 1 — Identify Longhorn Controllers =====
# See exactly which controllers own those pods
kubectl get pod -n default longhorn-csi-plugin-95cws -o wide
kubectl get pod -n default longhorn-csi-plugin-9drl8 -o wide
kubectl get pod -n default longhorn-csi-plugin-w4rvw -o wide
# List DaemonSets / Deployments to find Longhorn controllers
kubectl get ds,deploy -n default | grep -i longhorn
===== Step 2 — Delete Controllers =====
# If they are DaemonSets
kubectl delete ds longhorn-csi-plugin -n default --ignore-not-found
# If you see any of these deployments, delete them
kubectl delete deploy longhorn-manager longhorn-ui longhorn-driver-deployer \
-n default --ignore-not-found
# Remove one-shot jobs
kubectl delete job longhorn-pre-upgrade longhorn-post-upgrade -n default --ignore-not-found
===== Step 3 — Confirm No Longhorn Pods Remain =====
kubectl get pods -A | grep -i longhorn || echo "No Longhorn pods"
===== Step 4 — Delete All CRD Instances =====
for crd in $(kubectl get crd -o jsonpath={.items[*].metadata.name} | tr ' ' '\n' | grep longhorn.io); do
echo "Cleaning CRD: $crd"
kubectl delete "$crd" --all --wait=false || true
kubectl delete crd "$crd" --wait=false || true
done
Confirm CRDs are gone:
kubectl get crd | grep longhorn.io || echo "No Longhorn CRDs"
===== Step 5 — Remove Longhorn StorageClass =====
kubectl get storageclass | grep -i longhorn || echo "No Longhorn StorageClass"
# If something shows up, delete it:
kubectl delete storageclass longhorn --ignore-not-found
===== Step 6 — Remove Remaining Longhorn CRD Objects =====
# Check what remains
kubectl get backuptargets.longhorn.io --all-namespaces || echo "no backuptargets"
kubectl get engineimages.longhorn.io --all-namespaces || echo "no engineimages"
kubectl get nodes.longhorn.io --all-namespaces || echo "no nodes"
# Delete CSI deployments
kubectl delete deploy csi-attacher -n default --ignore-not-found
kubectl delete deploy csi-provisioner -n default --ignore-not-found
kubectl delete deploy csi-resizer -n default --ignore-not-found
kubectl delete deploy csi-snapshotter -n default --ignore-not-found
# Delete engine image DaemonSet
kubectl delete ds engine-image-ei-ff1cedad -n default --ignore-not-found
# Delete remaining CRD objects
kubectl delete backuptargets.longhorn.io --all -n default
kubectl delete engineimages.longhorn.io --all -n default
kubectl delete nodes.longhorn.io --all -n default
===== Step 7 — Remove Webhooks (if stuck) =====
kubectl delete ValidatingWebhookConfiguration longhorn-webhook-validator --ignore-not-found
kubectl delete MutatingWebhookConfiguration longhorn-webhook-mutator --ignore-not-found
===== Final Verification =====
kubectl get pods -A | grep -i longhorn || echo "No Longhorn pods"
kubectl get crd | grep longhorn.io || echo "No Longhorn CRDs"
kubectl get storageclass | grep -i longhorn || echo "No Longhorn StorageClass"