Deleting Longhorn 🐳
The longhorn team have (in a newer release) provided a code block that does flag the system to allow deletion:
kubectl -n longhorn-system patch -p '{"value": "true"}' --type=merge lhs deleting-confirmation-flagThe only downside is that, if you've broken your system beyond belief on installation, and you're trying to uninstall and re-install the helm chart you might run into the following:
Error from server (NotFound): settings.longhorn.io "deleting-confirmation-flag" not foundWhich means your system never got to the state where this flag was even created, which means you need to create the flag, not update it. There's some wacky ways of doing this, but the easiest I've found is by opening the default settings for longhorn:
kubectl -n longhorn-system edit configmap longhorn-default-settingThen you can add in deleting-confirmation-flag: true under the following section:
data:
default-setting.yaml: |-
# ADD IN HEREOh no, I tried to delete it before I changed this
Sometimes we make even bigger mistakes, if you get to the point where you cannot edit this file, nor can you finalize the delete of the environment, you can simply run the following:
kubectl get namespace longhorn-system -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/$NAMESPACE/finalize -f -