Skip to content

Instantly share code, notes, and snippets.

@lpsm-dev
Last active February 4, 2024 17:52
Show Gist options
  • Save lpsm-dev/0520e65577c41d7134245e57e84c3707 to your computer and use it in GitHub Desktop.
Save lpsm-dev/0520e65577c41d7134245e57e84c3707 to your computer and use it in GitHub Desktop.
[K8S] - Delete terminating namespace
# General
kubectl patch RESOURCE NAME -p '{"metadata":{"finalizers":[]}}' --type=merge
# Ingress
kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
kubectl patch ns ingress-nginx -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch ingress forwarding-ingress-nginx -n ingress-nginx -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch services ingress-nginx-production-controller -n ingress-nginx -p '{"metadata":{"finalizers":[]}}' --type=merge
# PVC
kubectl patch pvc s3-claim -n project-monolito -p '{"metadata":{"finalizers":[]}}' --type=merge
# Argocd
kubectl delete applications.argoproj.io external-secrets-production -n kube-system
kubectl delete applications.argoproj.io reloader-production -n kube-system
kubectl patch applications.argoproj.io external-secrets-production -n kube-system -p '{"metadata": {"finalizers": null}}' --type merge
kubectl patch applications.argoproj.io reloader-production -n kube-system -p '{"metadata": {"finalizers": null}}' --type merge
kubectl patch crd applications.argoproj.io -p '{"metadata": {"finalizers": null}}' --type merge
kubectl patch crd applicationsets.argoproj.io -p '{"metadata": {"finalizers": null}}' --type merge
kubectl patch crd appprojects.argoproj.io -p '{"metadata": {"finalizers": null}}' --type merge
kubectl delete crd applications.argoproj.io
kubectl delete crd applicationsets.argoproj.io
kubectl delete crd appprojects.argoproj.io
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get \
--show-kind --ignore-not-found -n argocd
# Rancher
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n cattle-fleet-system
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n cattle-impersonation-system
kubectl get customresourcedefinitions |grep management.cattle.io | awk '{print $1}' |xargs kubectl delete customresourcedefinitions
kubectl delete validatingwebhookconfigurations rancher.cattle.io
kubectl patch ns cattle-impersonation-system -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch ns cattle-fleet-system -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch ns cattle-system -p '{"metadata":{"finalizers":[]}}' --type=merge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment