helmfile destroy: Uninstall All Releases
helmfile destroy runs helm uninstall for every release in the helmfile, tearing the whole stack down.
For ephemeral preview environments, destroy is the cleanup step: it removes every release the helmfile created.
What it does
helmfile destroy uninstalls all releases defined in the current helmfile (honoring the selected environment and any selector). It is the inverse of sync. It does not delete the namespace itself unless a release managed it.
Common usage
# tear down a preview environment
helmfile -e "pr-$PR_NUMBER" destroy
# remove only one labeled group
helmfile destroy --selector app=apiOptions
| Flag | What it does |
|---|---|
| -e, --environment <name> | Select the environment to destroy |
| --selector key=value | Destroy only matching releases |
| --skip-charts | Skip the chart prepare/build phase |
In CI
Run destroy in a cleanup job when a pull request closes so preview namespaces do not accumulate. Use the same -e environment name you deployed with so destroy targets exactly that stack. destroy is safe to re-run: missing releases are skipped.
Common errors in CI
"Error: uninstall: Release not loaded: ...: release: not found" on a release that was never installed is benign and helmfile generally continues. If destroy leaves PVCs or CRDs behind, that is expected: helm does not delete PVCs from StatefulSets or CRDs by default. A stuck namespace usually has a finalizer on a leftover resource.
Using this in CI
A runner has no kubeconfig, no cached context, and no interactive auth. Every kubectl invocation in CI needs the context supplied explicitly, and most confusing CI failures here are the command running against the wrong cluster or no cluster at all.
# never rely on the ambient context on a runner
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get pods
# confirm what you are actually connected to before mutating anything
kubectl config current-context
kubectl cluster-info
# fail fast instead of hanging on an unreachable API server
kubectl --request-timeout=30s get nodes