delete namespace kubernetes code example

Example 1: kubectl create namespace

# Create Namespace in current cluster
kubectl create namespace my-namespace

Example 2: kubernetes get namespace

# Get Namespaces for current cluster
kubectl get namespaces

Example 3: kubernetes force delete namespace

(
NAMESPACE=your-rogue-namespace
rm temp.json
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
kill $(lsof -t -i:8001)
)