如何列出不存在的名称空间的所有对象? [英] How to list really all objects of a nonexistant namespace?

查看:61
本文介绍了如何列出不存在的名称空间的所有对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,标题很充实.但这实际上是在描述情况.

我在名称空间argo-events中的GKE上部署了服务.它出了点问题,所以我将其拆了:

  kubectl删除名称空间argo-events 

实际上,问题已经开始(我怀疑与下面描述的问题有关),我不得不求助于

argo-events未由 kubectl get命名空间列出.只是确认一下.

如果我专门查找它们,我可以找到这两个对象:

  $ kubectl get eventbus -n argo-events姓名年龄默认17小时$ kubectl获取事件源-n argo-events姓名年龄pubsub-event-source 14h 

但是-我无法通过询问所有对象找到任何东西:

  $ kubectl获得所有-n argo-events在argo-events命名空间中找不到资源. 

所以我的问题是.如何在Argo事件中通用列出所有挥之不去的对象?

我问,因为否则我将不得不检查整个对象浏览器树以找到更多对象(因为我无法再选择名称空间).

解决方案

使用命令 $ kubectl get all ,您将只打印一些资源,例如:

  • pod
  • 服务
  • daemonset
  • 部署
  • 复制包
  • statefulset
  • 工作
  • cronjobs

当您使用 $ kubectl api-resources 时,它不会打印所有可以找到的资源.

示例

kubectl get all不列出命名空间中的所有资源.在该线程中,您可能会发现上述命令的一些其他变体.

此外,您还可以检查hack because argo-events got stuck in a Terminating state forever. But the result was as desired - namespace seemed to be gone together with all objects in it.

Because of problems with redeployment I inspected the GKE Object Browser (just looking around - cannot filter for argo-events namespace anymore as it is officially gone) where I stumbled upon two lingering objects in ns argo-events:

argo-events is not listed by kubectl get namespaces. Just confirming that.

And I can find those two objects if I look them up specifically:

$ kubectl get eventbus -n argo-events
NAME      AGE
default   17h

$ kubectl get eventsource -n argo-events
NAME                  AGE
pubsub-event-source   14h

But - I cannot find anything by asking for all objects:

$ kubectl get all -n argo-events
No resources found in argo-events namespace.

So my question is. How can I generically list all lingering objects in argo-events?

I'm asking because otherwise I'd have to inspect the entire Object Browser Tree to maybe find more objects (as I cannot select the namespace anymore).

解决方案

By using command $ kubectl get all you will only print a few resources like:

  • pod
  • service
  • daemonset
  • deployment
  • replicaset
  • statefulset
  • job
  • cronjobs

It won't print all resources which can be found when you will use $ kubectl api-resources.

Example

When create PV from PersistentVolume docsumentation it won't be listed in $ kubectl get all output, but it will be listed if you will specify this resource.

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/pods/storage/pv-volume.yaml
persistentvolume/task-pv-volume created
$ kubectl get pv
NAME             CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
task-pv-volume   10Gi       RWO            Retain           Available           manual                  3m12s
$ kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.3.240.1   <none>        443/TCP   86m
$ 

If you would like to list all resources from specific namespace you should use command below:

kubectl -n argo-events api-resources --namespaced=true -o name | xargs --verbose -I {} kubectl -n argo-events get {} --show-kind --ignore-not-found

Above solution was presented in Github thread kubectl get all does not list all resources in a namespace. In this thread you might find some additional variations of above command.

In addition, you can also check How to List all Resources in a Kubernetes Namespace article. You can find there method to list resources using function.

这篇关于如何列出不存在的名称空间的所有对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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