Skip to content

Enhancement: Add cli switch to search all ALL un-namespaced objects (can be used in addition to the -n switch) #49

@spkane

Description

@spkane

I am working with a controller that manages a CRD which creates a namespace and then creates some additional resources in that namespace. With the current options, I am forced to search all namespaces to get the complete list of resources that this CRD resource owns.

  • A default search doesn't find anything (even though there is one non-namespaced child resource)
$ kubectl tree requests.project.example.com request-test

No resources are owned by this object through ownerReferences.
  • A single namespace search finds some of the resources, but does not list the one non-namespaced child resource.
$ kubectl tree requests.project.example.com request-test -n request-test

NAMESPACE     NAME                              READY  REASON  AGE
              Request/request-test              -              10m
request-test  ├─LimitRange/pod-resource-limits  -              10m
request-test  ├─ResourceQuota/pod-count         -              10m
request-test  └─RoleBinding/admin               -              10m
  • A search of all the namespaces finally finds all of the child resources, but it is overkill for what is actually needed.
$ kubectl tree requests.project.example.com request-test -A

NAMESPACE     NAME                              READY  REASON  AGE
              Request/request-test              -              6m48s
request-test  ├─LimitRange/pod-resource-limits  -              6m48s
              ├─Namespace/request-test          -              6m48s
request-test  ├─ResourceQuota/pod-count         -              6m48s
request-test  └─RoleBinding/admin               -              6m47s

It would be great to add a cli option like -C/--cluster-resources that could be used to specifically request that non-namespaced resources be checked. This should make it possible to find everything, without performing a overly broad search possible, using something like this:

$ kubectl tree requests.project.example.com request-test -n request-test -C

NAMESPACE     NAME                              READY  REASON  AGE
              Request/request-test              -              6m48s
request-test  ├─LimitRange/pod-resource-limits  -              6m48s
              ├─Namespace/request-test          -              6m48s
request-test  ├─ResourceQuota/pod-count         -              6m48s
request-test  └─RoleBinding/admin               -              6m47s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions