I would like to list all objects that are present in a specific namespace in kubernetes.
kubectl get all -n <namespace>
the above command doesn't list all available objects from the given namespace. Is there a way to list them using kubectl?
i can list all objects that i want by passing them to kubectl. but i dont want that.
kubectl -n <namespace> get deployment,rs,sts,ds,job,cronjobs -oyaml
The most basic command for viewing Kubernetes objects via kubectl is get . If you run kubectl get <resource-name> you will get a listing of all resources in the current namespace. If you want to get a specific resource, you can use kubectl get <resource-name> <object-name> .
First of all these following rules decide if the resource will be part of the all Category or not.
Here are the rules to add a new resource to the kubectl get all output.
No cluster scoped resources
No namespace admin level resources (limits, quota, policy,
authorization rules)
No resources that are potentially unrecoverable (secrets and pvc)
Resources that are considered "similar" to #3 should be grouped the
same (configmaps)
To Answer your question This is taken from rcorre's Answer
kubectl api-resources --verbs=list --namespaced -o name \
| xargs -n 1 kubectl get --show-kind --ignore-not-found -l <label>=<value> -n <namespace>
Lastly, If you want to add a Custom Resource in all category, you need to provide these field in your CRD spec. custom-resource-definitions:categories
# categories is a list of grouped resources the custom resource belongs to.
categories:
- all
Try:
kubectl -n your_namespace get all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With