Skip to content

Remove Operator

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

Important

This utility will not delete customer deployed add-ons and workloads because these are customer managed


Usage

Run the utility provided below with the imported cluster's "bootstrap yaml" that was generated by Rafay 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