Skip to content

Instantly share code, notes, and snippets.

@njgibbon
Created January 27, 2021 19:37
Show Gist options
  • Save njgibbon/0540b9e6054d3ec64bad1fdc500ea4e9 to your computer and use it in GitHub Desktop.
Save njgibbon/0540b9e6054d3ec64bad1fdc500ea4e9 to your computer and use it in GitHub Desktop.
Force removal of Kubernetes Namespace Finalizer(s).
set -eou pipefail
namespace=$1
if [ -z "$namespace" ]
then
echo "This script requires a namespace argument input. None found. Exiting."
exit 1
fi
kubectl get namespace $namespace -o json | jq '.spec = {"finalizers":[]}' > rknf_tmp.json
kubectl proxy &
sleep 5
curl -H "Content-Type: application/json" -X PUT --data-binary @rknf_tmp.json http://localhost:8001/api/v1/namespaces/$namespace/finalize
pkill -9 -f "kubectl proxy"
rm rknf_tmp.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment