Kubernetes: List objects from a specific api group (name collision)

name clash name collision

1 min read | by Jordi Prats

When we have different apiGroups providing objects with the same name (same kind), kubectl needs a way of telling them apart:

$ kubectl api-resources | grep '\bconfigs\b' configs config.gatekeeper.sh/v1alpha1 true Config configs operator.openshift.io/v1 false Config 

To be able to list of Config objects from the config.gatekeeper.sh/v1alpha1 apiGroup we'll need to use the following syntax:



kubectl get <object_name>.<version>.<api_group>



So, the kubectl get would be:

$ kubectl get config.v1.operator.openshift.io NAME AGE cluster 11m 

For config.gatekeeper.sh/v1alpha1 it would be:

$ kubectl get config.v1alpha1.config.gatekeeper.sh NAME AGE config 19s 

We can skip the version as well for retrieving all the objects regardless of the version:

$ kubectl get config.config.gatekeeper.sh NAME AGE config 8m16s 

Posted on 28/09/2022

Categories