๐ก Force Deleting Terminating Kubernetes โ Executive Summary
Technical architectural analysis, practical configuration manifests, and deployment instructions for Force Deleting Terminating Kubernetes.
References and Guidelines (NOTE)
Verify differences from existing test results in v1.33.5+k3s1 version.
- Existing
.spec.finalizers = []is not useful - Confirm normal deletion using the corresponding method
.metadata.finalizers = []
Delete namespace with PUT API request
bash
#jq ํจํค์ง ์ค์น ๋ฐ IP/Port ํ์ธ
yum install jq
kubectl proxy & #8001
ns=cert-manager
#yaml ํ์ผ๋ก ์ ์ฉํ temp.json ํ์ผ ์์ฑ
kubectl get namespace $ns -o json |jq '.spec = {"finalizers":[]}' > temp.json
#์์ ์ฌํญ ๋ฐ์
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json http://127.0.0.1:8001/api/v1/namespaces/$ns/finalize
rm temp.json
loop
Run loop by looking up Terminating
bash
kubectl proxy & #8001
for ns in $(kubectl get ns --no-headers | awk '/Terminating/ {print $1}'); do
echo "Force deleting namespace: $ns"
# ๋ค์์คํ์ด์ค JSON์ ๊ฐ์ ธ์ finalizers ์ ๊ฑฐ
kubectl get namespace "$ns" -o json \
| jq 'del(.spec.finalizers)' > temp.json
# curl PUT์ผ๋ก finalize API ํธ์ถ (kube-apiserver ํ๋ก์ ์ฌ์ฉ)
curl -k -H "Content-Type: application/json" \
-X PUT --data-binary @temp.json \
http://127.0.0.1:8001/api/v1/namespaces/"$ns"/finalize
rm temp.json
done
kuectl patch
bash
#metadata
for ns in $(kubectl get ns --no-headers | awk '/Terminating/ {print $1}'); do
echo "Force deleting namespace: $ns"
kubectl patch ns $ns --type='merge' -p='{"metadata": {"finalizers": []}}'
done




Leave a Reply