如何一次从Kubernetes删除所有资源? [英] How to delete all resources from Kubernetes one time?

查看:2139
本文介绍了如何一次从Kubernetes删除所有资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包括:

  • 守护程序集
  • 部署
  • 工作
  • 豆荚
  • 副本集
  • 复制控制器
  • 状态集
  • 服务
  • ...

如果具有复制控制器,则在删除某些部署时,它们将重新生成.有没有办法使kubenetes恢复初始状态?

If has replicationcontroller, when delete some deployments they will regenerate. Is there a way to make kubenetes back to initialize status?

推荐答案

Kubernetes命名空间将是您的理想选择.您可以轻松创建名称空间资源. kubectl create -f custom-namespace.yaml

Kubernetes Namespace would be the perfect options for you. You can easily create namespace resource. kubectl create -f custom-namespace.yaml

$ apiVersion: v1 kind: Namespace metadata: name:custom-namespace

$ apiVersion: v1 kind: Namespace metadata: name:custom-namespace

现在,您可以在该自定义名称空间中部署所有其他资源(Deployment,ReplicaSet,Services等).

Now you can deploy all of the other resources(Deployment,ReplicaSet,Services etc) in that custom namespaces.

如果要删除所有这些资源,则只需要删除自定义名称空间.通过删除自定义名称空间,所有其他资源都将被删除.没有它,ReplicaSet可能会在删除现有吊舱时创建新的吊舱.

If you want to delete all of these resources, you just need to delete custom namespace. by deleting custom namespace, all of the other resources would be deleted. Without it, ReplicaSet might create new pods when existing pods are deleted.

要使用命名空间,您需要在k8s命令中添加--namespace标志.

To work with Namespace, you need to add --namespace flag to k8s commands.

例如

kubectl create -f deployment.yaml --namespace=custom-namespace

您可以列出自定义命名空间中的所有Pod.

you can list all the pods in custom-namespace.

kubectl get pods --namespace=custom-namespace

这篇关于如何一次从Kubernetes删除所有资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆