列出命名空间中的所有资源 [英] Listing all resources in a namespace

查看:1355
本文介绍了列出命名空间中的所有资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查看命名空间中的所有资源.

I would like to see all resources in a namespace.

尽管名称为kubectl get all,但不会列出服务和入口之类的东西.

Doing kubectl get all will, despite of the name, not list things like services and ingresses.

如果我知道该类型,则可以明确要求该特定类型,但是似乎也没有命令列出所有可能的类型. (例如,kubectl get确实没有列出自定义类型.)

If I know the the type I can explicitly ask for that particular type, but it seems there is also no command for listing all possible types. (Especially kubectl get does for example not list custom types).

有什么主意,例如在删除该名称空间之前如何显示所有资源?

Any idea how to show all resources before for example deleting that namespace?

推荐答案

基于此注释,列出所有资源的受支持方法是遍历kubectl api-resources列出的所有api版本:

Based on this comment , the supported way to list all resources is to iterate through all the api versions listed by kubectl api-resources:

kubectl api-resources枚举集群中可用的资源类型.

kubectl api-resources enumerates the resource types available in your cluster.

这意味着您可以将其与kubectl get结合使用,以实际列出名称空间中每种资源类型的每个实例:

this means you can combine it with kubectl get to actually list every instance of every resource type in a namespace:

kubectl api-resources --verbs=list --namespaced -o name \
  | xargs -n 1 kubectl get --show-kind --ignore-not-found -l <label>=<value> -n <namespace>

这篇关于列出命名空间中的所有资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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