Uninstall a Kubernetes Replicated application


#1

Sometimes things don’t work. They break. And we need to start over. Sometimes spinning up a new server can take a long time. For someone who needs to start over on a Replicated instance that was created with the Replicated easy-setup script there are steps that can be followed to clean up the server.

Remove Replicated and Retraced

This will remove Replicated and ensure that it won’t interfere with any of the subsequent steps.

kubectl delete deployment `kubectl get deployment | grep -E "replicated|retraced" | awk '{print $1}'`
kubectl delete services `kubectl get services | grep -E "replicated|retraced" | awk '{print $1}'`

Remove the app

This step is optional. If a license was uploaded, then there is an application namespace that should be removed. If license was never uploaded, these commands will result in errors, and can be skipped.

appNSs=$(kubectl get ns | grep replicated- | awk '{ print $1 }')
for appNS in "$appNSs"; do kubectl delete ns "$appNS"; done

Remove Replicated and Retraced PVCs

kubectl delete pvc `kubectl get pvc | grep -E "replicated|retraced" | awk '{print $1}'`

Remove Rook/Ceph

CRD=`kubectl get crd | grep cluster | cut -d" " -f1` && kubectl patch crd $CRD -p '{"metadata":{"finalizers": null}}'
kubectl delete crd `kubectl get crd | grep rook | awk '{print $1}'`
kubectl delete ns `kubectl get ns | grep -E "rook|ceph" | awk '{print $1}'`

Remove stopped container and unused images

This step is optional. If there are any unused (stopped) containers and images, they will be deleted from the server.

docker rm `docker ps -aq`
docker rmi -f `docker images -q`

Remove Replicated and Rook data

This will delete Replicated snapshots that were stored in the default location on the same host.

rm -rf /var/lib/replicated
rm -rf /opt/replicated/rook
rm -rf /var/lib/rook