Skip to content

Instantly share code, notes, and snippets.

@philoserf
Last active October 2, 2023 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philoserf/24d32682672de41c5726972bf7ceaf23 to your computer and use it in GitHub Desktop.
Save philoserf/24d32682672de41c5726972bf7ceaf23 to your computer and use it in GitHub Desktop.
remove kubernetes namespace stuck in termiinating status
for ns in $(kubectl get ns --field-selector "status.phase=Terminating" --output "jsonpath='{.items[*].metadata.name}'"); do
kubectl get ns "${ns}" --output json |
jq '.spec.finalizers = []' |
kubectl replace --raw "/api/v1/namespaces/${ns}/finalize" --filename -
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment