Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Sort CRDs by their group #2557

Closed
leomichalski opened this issue Feb 23, 2024 · 3 comments
Closed

[Feature]: Sort CRDs by their group #2557

leomichalski opened this issue Feb 23, 2024 · 3 comments
Labels
enhancement New feature or request InProgress Marks an issue has being worked on

Comments

@leomichalski
Copy link

leomichalski commented Feb 23, 2024




Is your feature request related to a problem? Please describe.
I find it difficult to find CRDs when I type ":crds". There are a lot of CRDs, and they are alphabetically ordered. Also, I can't search them by a part of their name (some of them have long names).

Screenshot from 2024-02-22 21-21-42

Describe the solution you'd like
I'd like to see the CRDs grouped by their group (such as the cert-manager.io group).

Describe alternatives you've considered

  1. In the views.yaml columns section, allow to specify an attribute from the resource (such as spec.group). May be like this:
# $XDG_CONFIG_HOME/k9s/views.yaml
views:
  apiextensions.k8s.io/v1/customresourcedefinitions:
    # Overrides default sort column
    sortColumn: GROUP:asc
    columns:
      - NAME
      - VERSIONS
      - GROUP:.spec.group
      - AGE
  1. A plugin that shows the CRDs, but sorted by their group. I wrote a plugin like that, but it would be good to have this feature without the need for another plugin.
# $XDG_CONFIG_HOME/k9s/plugins.yaml
plugins:
  sort-crds-by-group:
    shortCut: s
    confirm: false
    description: Sort CRDs
    scopes:
      - customresourcedefinitions
    command: sh
    background: false
    args:
      - -c
      - "kubectl get crds -o=custom-columns=NAME:.metadata.name,GROUP:.spec.group --sort-by=.spec.group --context $CONTEXT | less -K"

Additional context

The first alternative would be similar to sorting the pods by their namespace, such as:

Screenshot from 2024-02-22 21-59-51

@leomichalski
Copy link
Author

leomichalski commented Feb 23, 2024

Would it be interesting to add the alternative 2 to https://github.com/derailed/k9s/tree/master/plugins? I could open a PR

@derailed derailed added enhancement New feature or request InProgress Marks an issue has being worked on labels Feb 28, 2024
@derailed
Copy link
Owner

@leomichalski Thank you for the heads up Leonardo!
CRD view indeed needs a little tlc as this should be readily available out of the box.
I'll push an update in the next drop...

derailed added a commit that referenced this issue Mar 2, 2024
@evgmoskalenko
Copy link

How can we now set :desc as the default everywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request InProgress Marks an issue has being worked on
Projects
None yet
Development

No branches or pull requests

3 participants