kubectl CRD 삭제

1 개요[ | ]

kubectl CRD 삭제
kubectl CRD 재귀 삭제
kubectl CRD 캐스케이드 삭제
  • 삭제대상 CRD 목록 조회
$ kubectl get crds -oname | grep cluster.x-k8s.io | sed 's|.*/||'
addonproviders.operator.cluster.x-k8s.io
bootstrapproviders.operator.cluster.x-k8s.io
clusterclasses.cluster.x-k8s.io
...
machinepools.cluster.x-k8s.io
machines.cluster.x-k8s.io
machinesets.cluster.x-k8s.io
  • 삭제대상 CRD 인스턴스 목록 조회
$ kubectl get crds -oname | grep cluster.x-k8s.io | sed 's|^.*/||' | xargs -n1 kubectl get -A -o custom-columns=":metadata.namespace,:kind,:metadata.name" | xargs -n3 echo
capi-kubeadm-bootstrap-system BootstrapProvider kubeadm
capi-kubeadm-control-plane-system ControlPlaneProvider kubeadm
capi-system CoreProvider cluster-api
docker-infrastructure-system InfrastructureProvider docker

2 방법 1: 인스턴스 자동 삭제[ | ]

  • CRD 삭제 명령어 생성
$ kubectl get crds -oname | grep cluster.x-k8s.io | sed 's|.*/||' | xargs -n1 echo kubectl delete crd --cascade=foreground
kubectl delete crd --cascade=foreground addonproviders.operator.cluster.x-k8s.io
kubectl delete crd --cascade=foreground bootstrapproviders.operator.cluster.x-k8s.io
kubectl delete crd --cascade=foreground clusterclasses.cluster.x-k8s.io
...
kubectl delete crd --cascade=foreground machinepools.cluster.x-k8s.io
kubectl delete crd --cascade=foreground machines.cluster.x-k8s.io
kubectl delete crd --cascade=foreground machinesets.cluster.x-k8s.io
  • CRD 삭제 명령어 실행
$ kubectl delete crd --cascade=foreground addonproviders.operator.cluster.x-k8s.io
customresourcedefinition.apiextensions.k8s.io "addonproviders.operator.cluster.x-k8s.io" deleted
...
$ kubectl delete crd --cascade=foreground machinepools.cluster.x-k8s.io
customresourcedefinition.apiextensions.k8s.io "machinepools.cluster.x-k8s.io" deleted
$ kubectl delete crd --cascade=foreground machinesets.cluster.x-k8s.io
customresourcedefinition.apiextensions.k8s.io "machinesets.cluster.x-k8s.io" deleted

3 방법 2: 인스턴스 수동 삭제[ | ]

  • CRD 인스턴스 삭제 명령어 생성
$ kubectl get crds -oname | grep cluster.x-k8s.io | sed 's|^.*/||' | xargs -n1 kubectl get -A -o custom-columns=":metadata.namespace,:kind,:metadata.name" | xargs -n3 echo kubectl delete -n
kubectl delete -n capi-kubeadm-bootstrap-system BootstrapProvider kubeadm
kubectl delete -n capi-kubeadm-control-plane-system ControlPlaneProvider kubeadm
kubectl delete -n capi-system CoreProvider cluster-api
kubectl delete -n docker-infrastructure-system InfrastructureProvider docker
  • CRD 인스턴스 삭제 명령어 실행
$ kubectl delete -n capi-kubeadm-bootstrap-system BootstrapProvider kubeadm
bootstrapprovider.operator.cluster.x-k8s.io "kubeadm" deleted
$ kubectl delete -n capi-kubeadm-control-plane-system ControlPlaneProvider kubeadm
controlplaneprovider.operator.cluster.x-k8s.io "kubeadm" deleted
$ kubectl delete -n capi-system CoreProvider cluster-api
coreprovider.operator.cluster.x-k8s.io "cluster-api" deleted
$ kubectl delete -n docker-infrastructure-system InfrastructureProvider docker
infrastructureprovider.operator.cluster.x-k8s.io "docker" deleted
  • CRD 삭제 명령어 생성
$ kubectl get crds -oname | grep cluster.x-k8s.io | sed 's|.*/||' | xargs -n1 echo kubectl delete crd
kubectl delete crd addonproviders.operator.cluster.x-k8s.io
kubectl delete crd bootstrapproviders.operator.cluster.x-k8s.io
kubectl delete crd clusterclasses.cluster.x-k8s.io
...
kubectl delete crd machinepools.cluster.x-k8s.io
kubectl delete crd machines.cluster.x-k8s.io
kubectl delete crd machinesets.cluster.x-k8s.io
  • CRD 삭제 명령어 실행
$ kubectl delete crd addonproviders.operator.cluster.x-k8s.io
customresourcedefinition.apiextensions.k8s.io "addonproviders.operator.cluster.x-k8s.io" deleted
...
$ kubectl delete crd machinepools.cluster.x-k8s.io
customresourcedefinition.apiextensions.k8s.io "machinepools.cluster.x-k8s.io" deleted
$ kubectl delete crd machinesets.cluster.x-k8s.io
customresourcedefinition.apiextensions.k8s.io "machinesets.cluster.x-k8s.io" deleted

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}