전자책 출간 알림 [마이크로서비스패턴 쉽게 개발하기]

티스토리 뷰

Cloud/Kubernetes

pv,pvc,namespace 강제 삭제

Happy@Cloud 2020. 9. 10. 22:21

[출처] nevido.tistory.com/640

pv나 pvc삭제시

kubectl delete pv/pv-name or pvc/pvc-name으로 안될때

--grace-period=0 이 옵션을 해보고 안되면 --grace-period=0 --force

 

이것도 안될경우

edit후 

- kubernetes.io/pv-protection

해당 부분이 존재하는지 확인해본다

만약 있다면

kubectl patch pvc pvc_name -p '{"metadata":{"finalizers":null}}'

 

kubectl patch pv pv_name -p '{"metadata":{"finalizers":null}}'

 

kubectl patch pod pod_name -p '{"metadata":{"finalizers":null}}'

 

이렇게 삭제할수 있다 

 

자세한 내용은 아래를 참고하길 바란다

https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#finalizers

 

Extend the Kubernetes API with CustomResourceDefinitions

This page shows how to install a custom resource into the Kubernetes API by creating a CustomResourceDefinition. Before you begin You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster.

kubernetes.io

 

namespace 강제 삭제는 아래와 같이 하십시오. ns환경변수에 지울 namespace명 넣고 실행하면 됩니다.

$ ns=myns

$ kubectl get namespace "${ns}" -o json \
  | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \
  | kubectl replace --raw /api/v1/namespaces/"${ns}"/finalize -f -

댓글

전자책 출간 알림 [마이크로서비스패턴 쉽게 개발하기]