Skip to content

Remove Operator

Simply Deleting/Removing an imported cluster in the Web Console (i.e. Controller) does not automatically remove all artifacts associated with the Kubernetes Mgmt Operator on imported clusters. We provide a tool that can be used to force remove/delete all remaining resources provisioned on imported clusters.

Important

This utility will not delete user deployed resources because these are managed by the customer.


Usage

Run the utility provided below with the imported cluster's "bootstrap yaml" that was generated by the controller during the import process.

./import-cluster-cleanup.sh my-cluster-bootstrap.yaml

Force Remove Script

#!/bin/bash
if [ $# -lt 1 ]; then
    echo "please specify the cluster bootstrap file location as an argument"
    echo  "Usage: ./import-cluster-cleanup.sh my-cluster-bootstrap.yaml" && exit -1
fi
kubectl delete ValidatingWebhookConfiguration rafay-drift-validate
kubectl scale deployment rafay-connector -n rafay-system --replicas=0
kubectl delete rt v1-logging-infra -n rafay-infra
kubectl delete rt v2-prometheus -n rafay-infra
kubectl delete rt v2-alertmanager -n rafay-infra
kubectl delete rt v1-debug-infra -n rafay-system
kubectl delete rt v1-edge-client -n rafay-system
kubectl delete rt v2-ingress -n rafay-system
kubectl delete rt v2-relay-agent -n rafay-system
kubectl delete rt rafay-restricted-psp -n rafay-system
kubectl delete rt rafay-privileged-psp -n rafay-system
kubectl delete rt v2-infra -n rafay-system
kubectl delete rtl v2-infra -n rafay-system
sleep 30
kubectl delete rns rafay-infra --timeout=10s
kubectl delete rns rafay-system --timeout=10s
kubectl proxy &
for NAMESPACE in rafay-system rafay-infra
do
kubectl get rns $NAMESPACE -o json |jq '.metadata.finalizers = []' > temp.json
curl -ks -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/apis/cluster.rafay.dev/v2/namespaces/default/namespaces/$NAMESPACE/ > /dev/null 2>&1
done
kubectl delete namespace rafay-infra --timeout=10s
kubectl delete namespace rafay-system --timeout=10s
for NAMESPACE in rafay-system rafay-infra
do
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' > temp.json
curl -ks -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize > /dev/null 2>&1
done
sleep 30
kubectl delete -f $1
killall -9 kubectl