Force Deleting Terminating Kubernetes

๐Ÿ’ก 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

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *