Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

uninstall guide should contains scripts to remove finalizers #900

Closed
survivant opened this issue Nov 19, 2020 · 2 comments · Fixed by #906
Closed

uninstall guide should contains scripts to remove finalizers #900

survivant opened this issue Nov 19, 2020 · 2 comments · Fixed by #906

Comments

@survivant
Copy link

survivant commented Nov 19, 2020

https://docs.openebs.io/docs/next/uninstall.html

like this

Ensure that there are no stale BlockDeviceClaims present in the cluster. You can verify the status using the following command.

kubectl get bdc -n <openebs namespace>

If present, remove the finalizer entry from the corresponding BDC.

it should includes the command to delete them.

like

root@test-pcl114:~# kubectl get bdc -n openebs
NAME                                             BLOCKDEVICENAME                           PHASE   AGE
bdc-cstor-49e263e4-82da-47b8-b5fc-83d7f9010e59   sparse-0352c127ae5e3c70a24bd9a476a31359   Bound   7d19h
bdc-cstor-806d324f-5a8b-4d80-bacc-2b33d8b914fc   sparse-23516928ac3e7cb19467d0f16bd5cdab   Bound   6d20h
root@test-pcl114:~#

You could provide a command line like this

 kubectl patch -n openebs bdc bdc-cstor-806d324f-5a8b-4d80-bacc-2b33d8b914fc -p '{"metadata":{"finalizers":null}}' --type=merge

or something like that

kubectl delete cspc -n openebs --all --wait=false
kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cspc -n openebs -o name)

@survivant
Copy link
Author

survivant commented Nov 26, 2020

Here a script that I created to uninstall OpenEBS

#!/bin/bash

# uninstall OpenEBS Helm chart
helm delete openebs -n openebs

# cleanup PVC
echo "Cleaning PVC"

STATUS=$(kubectl get pvc -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete pvc -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get pvc -n openebs -o name)
fi


# cleanup SPC
echo "Cleaning SPC"
STATUS=$(kubectl get spc -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete spc --all --wait=false
	kubectl patch -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get spc -o name)
fi

# cleanup BDC
echo "Cleaning BDC"
STATUS=$(kubectl get bdc -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete bdc -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get bdc -n openebs -o name)
fi

# cleanup CV
echo "Cleaning CV"
STATUS=$(kubectl get cv -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cv -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cv -n openebs -o name)
fi

# cleanup CVC
echo "Cleaning CVC"
STATUS=$(kubectl get cvc -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cvc -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cvc -n openebs -o name)
fi

# cleanup CVR
echo "Cleaning CVR"
STATUS=$(kubectl get cvr -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cvr -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cvr -n openebs -o name)
fi

# cleanup CSTORVOLUME
echo "Cleaning CSTORVOLUME"
STATUS=$(kubectl get cstorvolume -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cstorvolume -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cstorvolume  -n openebs -o name)
fi

# cleanup cbackup
echo "Cleaning cbackup"
STATUS=$(kubectl get cbackup -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cbackup -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cbackup -n openebs -o name)
fi

# cleanup ccompletedbackup
echo "Cleaning ccompletedbackup"
STATUS=$(kubectl get ccompletedbackup -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete ccompletedbackup -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get ccompletedbackup -n openebs -o name)
fi

# cleanup crestore
echo "Cleaning crestore"
STATUS=$(kubectl get crestore -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete crestore -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get crestore -n openebs -o name)
fi

# cleanup csp
echo "Cleaning csp"
STATUS=$(kubectl get csp -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete csp -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get csp -n openebs -o name)
fi

# cleanup CSPC
echo "Cleaning CSPC"
STATUS=$(kubectl get cspc -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cspc -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cspc -n openebs -o name)
fi

# cleanup CSPI
echo "Cleaning CSPI"
STATUS=$(kubectl get cspi -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete cspi -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get cspi -n openebs -o name)
fi

# cleanup BD
echo "Cleaning BD"
STATUS=$(kubectl get bd -n openebs -o name | wc -l)

if [ "$STATUS" -gt 0 ]; then
	kubectl delete bd -n openebs --all --wait=false
	kubectl patch -n openebs -p '{"metadata":{"finalizers":null}}' --type=merge $(kubectl get bd -n openebs -o name)
fi


# delete CRD

kubectl delete crd castemplates.openebs.io --wait=false
kubectl delete crd cstorpools.openebs.io --wait=false
kubectl delete crd cstorpoolinstances.openebs.io --wait=false
kubectl delete crd cstorvolumeclaims.openebs.io --wait=false
kubectl delete crd cstorvolumereplicas.openebs.io --wait=false
kubectl delete crd cstorvolumepolicies.openebs.io --wait=false
kubectl delete crd cstorvolumes.openebs.io --wait=false
kubectl delete crd runtasks.openebs.io --wait=false
kubectl delete crd storagepoolclaims.openebs.io --wait=false
kubectl delete crd storagepools.openebs.io --wait=false
kubectl delete crd volumesnapshotdatas.volumesnapshot.external-storage.k8s.io --wait=false
kubectl delete crd volumesnapshots.volumesnapshot.external-storage.k8s.io --wait=false
kubectl delete crd blockdevices.openebs.io --wait=false
kubectl delete crd blockdeviceclaims.openebs.io --wait=false
kubectl delete crd cstorbackups.openebs.io --wait=false
kubectl delete crd cstorbackups.cstor.openebs.io --wait=false
kubectl delete crd cstorrestores.openebs.io --wait=false
kubectl delete crd cstorcompletedbackups.openebs.io --wait=false
kubectl delete crd upgradetasks.openebs.io --wait=false
kubectl delete crd cstorpoolclusters.cstor.openebs.io --wait=false
kubectl delete crd cstorpoolinstances.cstor.openebs.io --wait=false
kubectl delete crd cstorvolumeattachments.cstor.openebs.io --wait=false
kubectl delete crd cstorvolumeconfigs.cstor.openebs.io --wait=false
kubectl delete crd cstorvolumepolicies.cstor.openebs.io --wait=false
kubectl delete crd cstorvolumereplicas.cstor.openebs.io --wait=false
kubectl delete crd cstorvolumes.cstor.openebs.io --wait=false
kubectl delete crd cstorcompletedbackups.cstor.openebs.io --wait=false
kubectl delete crd cstorrestores.cstor.openebs.io --wait=false



# validate that all CRD from OpenEBS are removed
kubectl api-resources | grep openebs
kubectl get crd | grep openebs



 
# cleanup PVC (sparse files)
rm -rf /var/openebs/

# deleting namespace
kubectl delete ns openebs --wait=false

# cleanup namespace finalizers

# be sure that everything else was deleted before

#kubectl get namespace openebs -o json | jq -j '.spec.finalizers=null' > tmp.json 
#kubectl replace --raw "/api/v1/namespaces/openebs/finalize" -f ./tmp.json

@Mohkam
Copy link

Mohkam commented Dec 17, 2020

thank you @survivant your script helped me out. i was banding my head in wall.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants