Listing All Resources in Kubernetes
Two quick and easy options of listing all the resources deployed in Kubernetes.
Setting a default namespace (optional):
kubectl config set-context --current --namespace=my-namespace
Option 1
# Listing all the standard (pod, service, etc.) k8s resources in specific namespace
kubectl get all -n my-namespace
# Listing all the standard k8s resources in current context's default namespace
kubectl get all
Option 2:
Or you can use function below. Advantage is that this function will list default resources and Custom Resources (CRDs) as well:
function kubectlgetall {
for i in $(kubectl api-resources --verbs=list --namespaced -o name | grep -v "events.events.k8s.io" | grep -v "events" | sort | uniq); do
echo "Resource:" $i
if [ -z "$1" ]
then
kubectl get --ignore-not-found ${i}
else
kubectl -n ${1} get --ignore-not-found ${i}
fi
done
}
Usage: kubectlgetall <namespace>
namespace is optional
Example: get all resources from the kafka
namespace:
kubectlgetall kafka
get all resources from default namespace:
kubectlgetall
References:
- Listing all resources in a namespace in Stackoverflow
- How to list all resources in a kubernetes namespace - Study Tonight
Feedback
For any feedback or request, don't hesitate, open an `issue` and let me know. Don't be shy.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.