k9s icon indicating copy to clipboard operation
k9s copied to clipboard

if the name of two CRD have same prefix,it can not distinguish CR

Open shiyishan2022 opened this issue 2 years ago • 10 comments




Describe the bug

In my cluster,there are two CRD,whose name look alike.Their name are both start with 'licenses'.

image

In fact,they have different CR now

image

image

However,in k9s,when I try to list CR for those two CRD separately,they all display the same CR

Let me guess,it is judged by only the first word 'licenses',so it can not distinguish the difference.

Versions :

  • OS: [Windows 10]
  • K9s: [0.25.18]
  • K8s: [1.20.0]

shiyishan2022 avatar Jul 01 '22 07:07 shiyishan2022

I noticed this as well and as a quick hack, I edited the crds singular and/or plural name at which point k9s was able to find it (it's possible that has some other implications, but I haven't noticed any issues yet). I do think it would be nice search for the fully qualified name of the crd within k9s

j2udev avatar Jul 01 '22 17:07 j2udev

I noticed this as well and as a quick hack, I edited the crds singular and/or plural name at which point k9s was able to find it (it's possible that has some other implications, but I haven't noticed any issues yet). I do think it would be nice search for the fully qualified name of the crd within k9s

I have tried the workaround you said, and it works. Thanks a lot. When I type in kubectl get licenses -A in bash, it lists CR that belongs to the first CRD. Maybe k9s straightly inherit some kind of mechanism from kubernetes, but I am a totally rookie for kubernetes and Golang.-_-

shiyishan2022 avatar Jul 03 '22 12:07 shiyishan2022

A workaround is to use the syntax used by output of kubectl api-resources i.e. group/version/name e.g. pkg.crossplane.io/v1alpha1/controllerconfigs

$ kubectl api-resources
NAME                                  SHORTNAMES          APIVERSION                                      NAMESPACED   KIND
[...]
controllerconfigs                                         pkg.crossplane.io/v1alpha1                      false        ControllerConfig
[...]
controllerconfigs                                         machineconfiguration.openshift.io/v1            false        ControllerConfig

gberche-orange avatar Jul 04 '22 09:07 gberche-orange

@gberche-orange Perfect, much better suggestion :) IMO this could probably be closed so long as there is a way to distinguish the custom resources from one another without needing to modify them.

j2udev avatar Jul 05 '22 13:07 j2udev

@gberche-orange Thank you!!

Right, as the crd command space is getting a bit crowded conflicts are unavoidable. Don't forget tho even in this case, k9s has your back! and it's even doc'ed out custom alias Surprised? I haven't tested this in a while but in Guillaume's case, one could define a couple of custom aliases ie ccc and cco for crossplane vs openshift controllerconfigs. It's well known that I suck at typing thus custom aliases are handy when there are no shortnames but also when there are conflicts and one must specified the full gvr. Who has time for that??

Another tip from your uncle Larry ;)

derailed avatar Jul 05 '22 14:07 derailed

Yet another awesome feature of k9s :) will definitely have to look into using that!

j2udev avatar Jul 05 '22 15:07 j2udev

Haha, got it. It's a good method, just spend a moment to remember the 'APIVERSION' and 'NAME' for each one. @j2udevelopment @derailed @gberche-orange Thank you!

shiyishan2022 avatar Jul 05 '22 15:07 shiyishan2022

Someone who has same confusion, try to find the description of CRD and concat 'spec.group','spec.versions.name' and 'spec.names.plural'. K9S can distinguish it. And you could also find the combination by command kubectl api-resources , as @gberche-orange mentioned in this thread.

shiyishan2022 avatar Jul 05 '22 15:07 shiyishan2022

A nice evolution for k9s would be to use the ${group}/${version}/${name} syntax in the crds view when pressing Return key goes from a crd to list of related cr.

As a workaround, I'll trying crafting a k9s plugin which displays the syntax to use within the crd view. Can't go much further since AFAIK plugins don't yet allow to browse within k9s screens but only launch external commands.

gberche-orange avatar Jul 06 '22 12:07 gberche-orange

Seems related: if I go to the "crds" screen (:crds), I can press enter on a CRD to list all its resources. However that doesn't work if there is another CRD with the same short name.

manno avatar Sep 19 '22 09:09 manno