How to delete all resources from Kubernetes one time?

后端 未结 3 1958
暗喜
暗喜 2020-12-23 16:10

Include:

  • Daemon Sets
  • Deployments
  • Jobs
  • Pods
  • Replica Sets
  • Replication Controllers
  • Stateful Sets
  • Se
3条回答
  •  情歌与酒
    2020-12-23 16:40

    You can also delete Kubernetes resources with the help of labels attached to it. For example, suppose below label is attached to all resource

    metadata:
      name: label-demo
      labels:
        env: dev
        app: nginx
    

    now just execute the below commands

    deleting resources using app label
    $ kubectl delete pods,rs,deploy,svc,cm,ing -l app=nginx
    
    deleting resources using envirnoment label
    $ kubectl delete pods,rs,deploy,svc,cm,ing -l env=dev
    

提交回复
热议问题