Add print columns for CRDs in kubectl output#11805
Open
caseydavenport wants to merge 4 commits intoprojectcalico:masterfrom
Open
Add print columns for CRDs in kubectl output#11805caseydavenport wants to merge 4 commits intoprojectcalico:masterfrom
caseydavenport wants to merge 4 commits intoprojectcalico:masterfrom
Conversation
21bb924 to
adcb635
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to improve kubectl get output for Calico CRDs by adding additionalPrinterColumns (via +kubebuilder:printcolumn markers and/or direct CRD YAML updates), surfacing key spec/status fields in tabular output.
Changes:
- Added/updated
+kubebuilder:printcolumnmarkers across multiple CRD API types (policies, IPAM, BGP, node status, etc.). - Updated several generated CRD YAMLs under
api/config/crd/to includeadditionalPrinterColumns. - Introduced new columns such as Tier/Order, node/classes, claim time, and cluster readiness/version.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| api/pkg/apis/projectcalico/v3/stagednetworkpolicy.go | Adds printer column for policy order (currently with naming/type issues). |
| api/pkg/apis/projectcalico/v3/stagedglobalnetworkpolicy.go | Adds printer column for policy order. |
| api/pkg/apis/projectcalico/v3/nodestatus.go | Adds printer columns for node name and monitored classes. |
| api/pkg/apis/projectcalico/v3/networkpolicy.go | Adds printer column for policy order. |
| api/pkg/apis/projectcalico/v3/kubecontrollersconfig.go | Adds printer column for enabled controllers (currently attached to list type + JSONPath concerns). |
| api/pkg/apis/projectcalico/v3/ipamhandle.go | Adds printer column for handle ID. |
| api/pkg/apis/projectcalico/v3/ipamconfig.go | Adds printer columns for key IPAM config fields (currently attached to list type + description issue). |
| api/pkg/apis/projectcalico/v3/ipamblocks.go | Adds printer column for affinity claim time (and surfaces existing column-name typo). |
| api/pkg/apis/projectcalico/v3/hostendpoint.go | Adds printer columns for node/interface (currently attached to list type). |
| api/pkg/apis/projectcalico/v3/globalnetworkset.go | Adds printer column for age (currently attached to list type). |
| api/pkg/apis/projectcalico/v3/globalnetworkpolicy.go | Adds printer columns for order/age (currently attached to list type). |
| api/pkg/apis/projectcalico/v3/clusterinfo.go | Adds printer columns for version, readiness, and cluster types. |
| api/pkg/apis/projectcalico/v3/blockaffinity.go | Adds printer column for affinity type. |
| api/pkg/apis/projectcalico/v3/bgppeer.go | Adds printer columns for BGP peer fields (currently attached to list type + ASN type concerns). |
| api/config/crd/projectcalico.org_stagednetworkpolicies.yaml | Adds .spec.order printer column (currently with naming/type issues). |
| api/config/crd/projectcalico.org_stagedglobalnetworkpolicies.yaml | Adds .spec.order printer column. |
| api/config/crd/projectcalico.org_networkpolicies.yaml | Adds .spec.order printer column. |
| api/config/crd/projectcalico.org_ipamhandles.yaml | Adds handle ID printer column. |
| api/config/crd/projectcalico.org_ipamblocks.yaml | Adds affinity claim time printer column (and contains existing column-name typo). |
| api/config/crd/projectcalico.org_clusterinformations.yaml | Adds version/ready/types printer columns. |
| api/config/crd/projectcalico.org_caliconodestatuses.yaml | Adds node/classes printer columns. |
| api/config/crd/projectcalico.org_blockaffinities.yaml | Adds type printer column. |
Comments suppressed due to low confidence (4)
api/pkg/apis/projectcalico/v3/ipamconfig.go:30
- The
StrictAffinityprinter column description is inverted. The API field docs state: "When StrictAffinity is true, borrowing IP addresses is not allowed"; the column description currently says borrowing is allowed. Please update the description to match the actual semantics to avoid misleading kubectl output.
// IPAMConfigurationList contains a list of IPAMConfiguration resources.
api/pkg/apis/projectcalico/v3/bgppeer.go:34
- The new
+kubebuilder:printcolumnmarkers are currently attached toBGPPeerList(the next type), so they won't be reflected in the generated CRD (api/config/crd/projectcalico.org_bgppeers.yamlhas noadditionalPrinterColumns). Move these markers to theBGPPeertype and regenerate CRDs. Also,.spec.asNumber/.spec.localASNumberare integers in the CRD schema, so use an integer/number column type for those fields.
// BGPPeerList is a list of BGPPeer resources.
type BGPPeerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`
api/pkg/apis/projectcalico/v3/globalnetworkpolicy.go:33
- These print columns are currently on
GlobalNetworkPolicyList(the next type), not theGlobalNetworkPolicyresource type, so they won't be emitted into the CRD (api/config/crd/projectcalico.org_globalnetworkpolicies.yamlhas noadditionalPrinterColumns). Move the markers toGlobalNetworkPolicyand regenerate CRDs so kubectl output actually changes.
// +kubebuilder:resource:scope=Cluster
// GlobalNetworkPolicyList is a list of Policy objects.
type GlobalNetworkPolicyList struct {
metav1.TypeMeta `json:",inline"`
api/pkg/apis/projectcalico/v3/ipamconfig.go:31
- These
+kubebuilder:printcolumnmarkers are attached toIPAMConfigurationList(the next type), but the generated CRD (api/config/crd/projectcalico.org_ipamconfigurations.yaml) currently has noadditionalPrinterColumns. Move the printcolumn markers to theIPAMConfigurationtype (the CRD root) and regenerate the CRDs so the columns show up in kubectl.
// +kubebuilder:resource:scope=Cluster
// IPAMConfigurationList contains a list of IPAMConfiguration resources.
type IPAMConfigurationList struct {
adcb635 to
351c974
Compare
351c974 to
a105f02
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add basic information to kubectl output for our CRDs using printcolums
Related issues/PRs
Todos
Release Note
Reminder for the reviewer
Make sure that this PR has the correct labels and milestone set.
Every PR needs one
docs-*label.docs-pr-required: This change requires a change to the documentation that has not been completed yet.docs-completed: This change has all necessary documentation completed.docs-not-required: This change has no user-facing impact and requires no docs.Every PR needs one
release-note-*label.release-note-required: This PR has user-facing changes. Most PRs should have this label.release-note-not-required: This PR has no user-facing changes.Other optional labels:
cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.