Skip to content

Instantly share code, notes, and snippets.

@iamcryptoki
Created October 28, 2021 12:40
Show Gist options
  • Select an option

  • Save iamcryptoki/596d580f4221a8b9f2839f1459922d21 to your computer and use it in GitHub Desktop.

Select an option

Save iamcryptoki/596d580f4221a8b9f2839f1459922d21 to your computer and use it in GitHub Desktop.
Delete Kubernetes namespaces stuck at terminating.
for ns in $(kubectl get ns --field-selector status.phase=Terminating -o jsonpath='{.items[*].metadata.name}'); do kubectl get ns $ns -ojson | jq '.spec.finalizers = []' | kubectl replace --raw "/api/v1/namespaces/$ns/finalize" -f -; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment