kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

Need a command to list all available/existing types (or resources) in a cluster

Open mihnjong opened this issue 9 years ago • 20 comments

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see http://kubernetes.io/docs/troubleshooting/.): no. kubectl get all --all-namespaces does not show all resources such as secrets.

What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.): "secrets", "all resources", "all types".


Is this a BUG REPORT or FEATURE REQUEST? (choose one): FEATURE REQUEST

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.6", GitCommit:"4bc5e7f9a6c25dc4c03d4d656f2cefd21540e28c", GitTreeState:"clean", B
uildDate:"2017-09-14T06:55:55Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.6-gke.1", GitCommit:"407dbfe965f3de06b332cc22d2eb1ca07fb4d3fb", GitTreeState:"cl
ean", BuildDate:"2017-09-27T21:21:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

Environment: Google Container Engine

  • Details:

    • Node version: 1.7.6
    • Node image: Container-Optimized OS (cos)
    • Machine type: n1-standard-1 (1 vCPU, 3.75 GB memory)
    • Total cores : 3 vCPUs
    • Total memory: 11.25 GB
  • Cloud provider or hardware configuration:

  • OS (e.g. from /etc/os-release):

  • Kernel (e.g. uname -a):

  • Install tools:

  • Others:

What happened:

kubectl get all --all-namespaces does not show all existing resources such as Secrets.

What you expected to happen:

kubectl get all --all-namespaces shows all existing resources such as Secrets as well as all resource types from other API servers.

How to reproduce it (as minimally and precisely as possible):

kubectl get all --all-namespaces

Anything else we need to know:

"all" should mean all the resources, not some of important resources.

mihnjong avatar Nov 01 '17 01:11 mihnjong

@mihnjong https://github.com/kubernetes/kubernetes/pull/42873

shiywang avatar Nov 01 '17 01:11 shiywang

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Jan 30 '18 02:01 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten /remove-lifecycle stale

fejta-bot avatar Mar 01 '18 02:03 fejta-bot

/remove-lifecycle rotten

mengqiy avatar Mar 01 '18 16:03 mengqiy

It is intended to not show Secrets when kubectl get all --all-namespaces

mengqiy avatar Mar 01 '18 16:03 mengqiy

It is intended to not show Secrets when kubectl get all --all-namespaces

@mengqiy To confirm, we don't want to show Secrets with kubectl get all, right? The description of the issue says that we should show Secrets...

I agree that Secrets should not be shown in kubectl get all. IIUC the current behavior is that Secrets are not shown so this can be closed now.

nikhita avatar Mar 02 '18 03:03 nikhita

Would be nice to have, because kubectl get all doesn't show custom resources

Paxa avatar Mar 05 '18 16:03 Paxa

kubectl get all doesn't show custom resources

This is now possible: https://github.com/kubernetes/kubernetes/pull/59561

nikhita avatar Mar 05 '18 16:03 nikhita

@nikhita FYI https://github.com/kubernetes/community/blob/master/contributors/devel/kubectl-conventions.md#rules-for-extending-special-resource-alias---all

You may want to update it if it's not accurate for CRD.

mengqiy avatar Mar 05 '18 22:03 mengqiy

You may want to update it if it's not accurate for CRD.

@mengqiy Sorry, missed the edit before. I think it is accurate for CRDs. kubectl get all doesn't show CRDs because they are cluster scoped resources. CRs don't follow that so it is possible to list them via kubectl get all.

nikhita avatar Apr 03 '18 06:04 nikhita

https://github.com/kubernetes/kubernetes/pull/42873 provides the api-resources command that lists all available types

/close

liggitt avatar Apr 14 '18 14:04 liggitt

I've found a few of these issues which are closed asking for more or less the same thing. Can we add a pointer to how to list ALL resources of ALL types? I'm diagnosing issues on K8 clusters where things generate more things and it gets hairy if there isn't a simple way to just list all of the things or see what all of the options are for things that can be out there.

drcrook1 avatar Jul 27 '18 01:07 drcrook1

in 1.11, https://github.com/kubernetes/kubernetes/pull/63254 added the ability to list all resource types in a format that can be used with kubectl get:

kubectl api-resources --verbs=list -o name | xargs -n 1 kubectl get -o name

liggitt avatar Jul 27 '18 14:07 liggitt

this does not get things in all namespaces

AceHack avatar Aug 30 '19 17:08 AceHack

this does not get things in all namespaces

you can add --all-namespaces if you want to get that

liggitt avatar Aug 30 '19 17:08 liggitt

You may want to update it if it's not accurate for CRD.

@mengqiy Sorry, missed the edit before. I think it is accurate for CRDs. kubectl get all doesn't show CRDs because they are cluster scoped resources. CRs don't follow that so it is possible to list them via kubectl get all.

I still don't understand why kubectl get all --all-namespaces didn't show all custom resources? What is "CRs don't follow that so it is possible to list them via kubectl get all." mean? Which part of CRs in kubenetes possible to list ? Thx~

workhardcc avatar Nov 29 '19 03:11 workhardcc

Doesn't kubectl api-resources work for you?

srknc avatar Dec 10 '19 20:12 srknc

Doesn't kubectl api-resources work for you?

The output of that is the list of all custom resource definitions that have been registered.

@workhardcc is wondering about kubectl get all which only (in my mind) would be expected to display all object including the ones that correspond to a custom resource. Right now, kubectl get all only shows the built-in Kubernetes resources, no CRD-defined resources.

For example: when you have cert-manager installed, kubectl get all does not show the Certificates or Orders that cert-manager stores.

Note: this issue is centered on listing object types, not object contents; maybe we should move that discussion to a new issue. I think https://github.com/kubernetes/kubectl/issues/151 talks about exactly that 🙂

maelvls avatar Mar 25 '20 17:03 maelvls

Why don't the kubectl api-resources and kubectl get crd commands return the same results?

Here is output of commands executed as a cluster admin user :

$ kubectl api-resources --verbs=list -o name | wc -l
140
$ kubectl get crd -o name | wc -l
82

fredgate avatar Apr 07 '21 09:04 fredgate

@fredgate because not all resources are CRDs?

pims avatar Apr 21 '21 22:04 pims