#!/usr/bin/env bash


helm uninstall rancher-2-7-0 -n cattle-system
helm uninstall -n cattle-fleet-system fleet
helm uninstall -n cattle-fleet-system fleet-crd
helm uninstall -n cattle-fleet-local-system fleet-agent-local
helm uninstall -n cattle-system rancher-webhoo

for kindof in  ns
do
  kubectl delete --force $kindof $(kubectl get $kindof | grep -v "kube" | grep -v "default"|  grep -v "local" |  grep -v "ingress"|  grep -v "traefix" | grep -v "NAME" | grep -v "cert" | awk '{print$1}')


done

 $(kubectl get $kindof | grep -v "kube" | grep -v "default"|  grep -v "local" |  grep -v "ingress"|  grep -v "traefix" | grep -v "NAME" | grep -v "cert" | awk '{print$1}')

for namespace in cattle-system
do
  echo "current nsmaespace is $namespace"
  kubectl proxy &
  kubectl get namespace $namespace -o json |jq '.spec = {"finalizers":[]}' >temp.json
  curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$namespace/finalize

  echo ""
done