Skip to content

Remove entity from kubernetes database

For example when using lognhorn or rook-ceph, often the delete is stuck in "Terminating" state because of finalizers.

If you can't patch the finalizers entry to an empty array:

sh
kubectl patch namespace mynamespace -p '{"spec": {"finalizers": []}}' --type=merge

You can directly remove the entity from kubernetes database with the following command:

sh
sudo systemctl stop k3s
sudo sqlite3 /var/lib/rancher/k3s/server/db/state.db
SELECT name FROM kine WHERE name LIKE '%longhorn%';
DELETE FROM kine WHERE name LIKE '%longhorn%';
.exit
sudo systemctl start k3s