Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Enhance kubectl get crd output to include extra metadata beyond Name and Created-At #131599

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
Loading
from

Conversation

jaehanbyun
Copy link

@jaehanbyun jaehanbyun commented May 3, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Enhance kubectl get crd output to include extra metadata beyond Name and Created-At for better visibility of CustomResourceDefinitions.

  • Before (default columns only showed NAME and CREATED AT):
$ kubectl get crd
NAME                      CREATED AT
foos.sample.example.com   2025-05-03T16:36:32Z
  • After (now shows NAME, GROUP, SCOPE, VERSIONS, and CREATED AT):
$ kubectl get crd
NAME                      GROUP                SCOPE        VERSIONS     CREATED AT
foos.sample.example.com   sample.example.com   Namespaced   v1,v1beta1   2025-05-03T16:36:32Z

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

This PR implements a default TableConvertor for CRDs.

Does this PR introduce a user-facing change?

`kubectl get crd` now displays additional columns—GROUP, SCOPE, VERSIONS, and CREATED AT—alongside NAME.  

This provides at-a-glance visibility into the API group, scope (Cluster‑ or Namespaced), served versions (comma‑separated), and exact creation timestamp of each CustomResourceDefinition.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 3, 2025
Copy link

linux-foundation-easycla bot commented May 3, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 3, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @jaehanbyun!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @jaehanbyun. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 3, 2025
@k8s-ci-robot k8s-ci-robot requested review from carlory and jpbetz May 3, 2025 17:58
@k8s-ci-robot k8s-ci-robot added area/kubeadm sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 3, 2025
@jaehanbyun jaehanbyun changed the title Crd table columns Enhance kubectl get crd output to include Group, Scope, Versions, and Created At columns May 3, 2025
@jaehanbyun jaehanbyun force-pushed the crd-table-columns branch from 787ff8f to 84d47ed Compare May 3, 2025 18:17
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 3, 2025
@carlory
Copy link
Member

carlory commented May 6, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 6, 2025
@jpbetz
Copy link
Contributor

jpbetz commented May 6, 2025

Group seems a bit redundant given that it's already in the name. Maybe only display that when -o wide is set?

@jpbetz
Copy link
Contributor

jpbetz commented May 6, 2025

Does VERSIONS show all versions or only served versions?

I'm usually most interested in seeing the served versions, and among the stored versions, I'm interested to know which is the stored version.

@jpbetz
Copy link
Contributor

jpbetz commented May 6, 2025

Other possible fields to consider (maybe only for -o wide) would be kind, short name, and the "Established" status.

@jpbetz
Copy link
Contributor

jpbetz commented May 6, 2025

Run a full make update to address the pull-kubernetes-verify failures.

@jaehanbyun
Copy link
Author

jaehanbyun commented May 6, 2025

@jpbetz

Group seems a bit redundant given that it's already in the name. Maybe only display that when -o wide is set?

It makes sense, got it!

Does VERSIONS show all versions or only served versions?
I'm usually most interested in seeing the served versions, and among the stored versions, I'm interested to know which is the stored version.

Currently output all versions. I think you meant you’d like to see only served: true versions, with the storage: true one marked.
For example:

$ kubectl get crd -o wide
NAME                     SCOPE       VERSIONS            CREATED AT            GROUP               KIND  SHORTNAMES  ESTABLISHED  
foos.sample.example.com  Namespaced  v1(storage),v1beta  2025-05-03T16:36:32Z  sample.example.com  Foo   f           True      

Does that look good?

Run a full make update to address the pull-kubernetes-verify failures.

Thanks, I’ll give that a try!

@jpbetz
Copy link
Contributor

jpbetz commented May 6, 2025

I think you meant you’d like to see only served: true versions, with the storage: true one marked.

This is roughly the information I'd like access to.

I'll defer to @kubernetes/sig-cli-leads for how the information should best be represented. I don't know if marking the storage version in this way is a good practice or not, but this is the information I consider most useful.

Thanks!

/assign @kubernetes/sig-cli-leads

@jaehanbyun
Copy link
Author

@jpbetz Thanks for the comment!
I’ll start by implementing the approach you recommended and will incorporate any feedback on the display format as I go.

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/remove-sig cluster-lifecycle
/remove-area kubeadm

@k8s-ci-robot k8s-ci-robot removed sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. area/kubeadm labels May 6, 2025
@aaron-prindle
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 6, 2025
@jaehanbyun jaehanbyun force-pushed the crd-table-columns branch from 84d47ed to af2f96b Compare May 12, 2025 13:25
@jaehanbyun jaehanbyun changed the title Enhance kubectl get crd output to include Group, Scope, Versions, and Created At columns Enhance kubectl get crd output to include extra metadata beyond Name and Created-At May 12, 2025
@jaehanbyun
Copy link
Author

@jpbetz PTAL:

I’ve implemented the changes so that:

$ k get crd
NAME                      SCOPE        VERSIONS              CREATED AT
foos.sample.example.com   Namespaced   v1(storage),v1beta1   2025-05-12T13:36:01Z

And with -o wide:

$ k get crd -o wide
NAME                      SCOPE        VERSIONS              CREATED AT             GROUP                KIND   SHORTNAMES   ESTABLISHED
foos.sample.example.com   Namespaced   v1(storage),v1beta1   2025-05-12T13:36:01Z   sample.example.com   Foo    f            true

Please take a look and let me know if you’d like any adjustments!

@jaehanbyun
Copy link
Author

/test pull-kubernetes-verify

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 14, 2025
Signed-off-by: jaehanbyun <awbrg789@naver.com>
Signed-off-by: jaehanbyun <awbrg789@naver.com>
- Add crdConvertor in tableconvertor.go under staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition
- Swap REST store’s default TableConvertor to use new crdConvertor via crdtable.New()
- Define table columns:
    • Name        (format:name)
    • Scope       (Cluster or Namespaced)
    • Versions    (comma-separated, sorted list of served versions, with `(storage)` suffix for the storage version)
    • Created At  (RFC3339 timestamp)
    • Group       (API group of the CRD)
    • Kind        (CustomResource kind)
    • ShortNames  (comma-separated)
    • Established (boolean)
- Add unit tests

Signed-off-by: jaehanbyun <awbrg789@naver.com>
@jaehanbyun jaehanbyun force-pushed the crd-table-columns branch from af2f96b to a12b18b Compare May 18, 2025 10:11
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 18, 2025
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - thank you! I've personally wanted to see more of that information when getting CRDs.

/lgtm
/approve
/label tide/merge-method-sqaush

@k8s-ci-robot
Copy link
Contributor

@soltysh: The label(s) /label tide/merge-method-sqaush cannot be applied. These labels are supported: api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda, refactor, ci-short, ci-extended, ci-full, official-cve-feed. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to this:

This looks great - thank you! I've personally wanted to see more of that information when getting CRDs.

/lgtm
/approve
/label tide/merge-method-sqaush

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: a5d8a977fa1851fa3489a83861ef01f65d5d628a

@soltysh
Copy link
Contributor

soltysh commented May 21, 2025

/label tide/merge-method-squash

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jaehanbyun, soltysh
Once this PR has been reviewed and has the lgtm label, please assign sttts for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jaehanbyun
Copy link
Author

/assign @sttts

@jaehanbyun
Copy link
Author

@jpbetz, could you take a look at this PR when you have a moment? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.