Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Add custom columns to OpenAPI schema #1597

Merged

Conversation

luksa
Copy link
Contributor

@luksa luksa commented Nov 22, 2017

Fixes #1361

This adds the required x-kubernetes-print-columns extensions to the OpenAPI schema, which allow kubectl to show sensible columns when listing service catalog resources:

$ kubectl get clusterservicebrokers
NAME         STATUS
ups-broker   FetchedCatalog

$ kubectl get clusterserviceclasses
NAME                                   EXTERNAL-NAME           BROKER       BINDABLE
4f6e6cf6-ffdd-425f-a2c7-3c9258ad2468   user-provided-service   ups-broker   true

$ kubectl get clusterserviceplans
NAME                                   EXTERNAL-NAME   BROKER       CLASS
86064792-7ea2-467b-af93-ac9694d96d52   default         ups-broker   4f6e6cf6-ffdd-425f-a2c7-3c9258ad2468
cc0d7529-18e8-416d-8946-6f7456acd589   premium   ups-broker   4f6e6cf6-ffdd-425f-a2c7-3c9258ad2468

$ kubectl get serviceinstances
NAME           CLASS                   PLAN      STATUS
ups-instance   user-provided-service   default   ProvisionedSuccessfully

$ kubectl get servicebindings
NAME          INSTANCE       SECRET        STATUS
ups-binding   ups-instance   ups-binding   InjectedBindResult

I've also added the AGE column (like the one displayed for core k8s resources), but that requires changes to kubectl, so I'll put that into a different PR.

Note:

  • this PR also Includes changes from PR make apiserver serve openapi #1208
  • to try it out, you need the to build kubectl from master, or use the --experimental-use-openapi-print-columns option

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2017
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 20, 2017
Copy link
Contributor

@pmorie pmorie left a comment

Choose a reason for hiding this comment

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

I like the direction this moves us in a lot, thanks for doing this.

I do have some concerns about how status is handled (suggest we punt status to another PR), and a couple suggestions for columns to add.

@@ -427,6 +430,7 @@ type ExtraValue []string
// In the future, this will be allowed and will represent the intention that
// the ServiceInstance should have the plan and/or parameters updated at the
// ClusterServiceBroker.
// +k8s:openapi-gen=x-kubernetes-print-columns:custom-columns=NAME:.metadata.name,CLASS:.spec.clusterServiceClassExternalName,PLAN:.spec.clusterServicePlanExternalName,STATUS:.status.conditions[*].reason
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how flexible we can be here with status. I'm not sure the current formulation of status is going to be useful - how about remove the STATUS bits and deal with status in a subsequent PR?

@@ -320,6 +322,7 @@ type ClusterServicePlanList struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterServicePlan represents a tier of a ServiceClass.
// +k8s:openapi-gen=x-kubernetes-print-columns:custom-columns=NAME:.metadata.name,EXTERNAL NAME:.spec.externalName,BROKER:.spec.clusterServiceBrokerName,CLASS:.spec.clusterServiceClassRef.name
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the CLASS column as it is defined here is probably useful and an improvement over nothing.

With that said I think this is an area where a kubectl plugin could help immensely.

cc @jberkhahn

@@ -225,6 +226,7 @@ type ClusterServiceClassList struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterServiceClass represents an offering in the service catalog.
// +k8s:openapi-gen=x-kubernetes-print-columns:custom-columns=NAME:.metadata.name,EXTERNAL NAME:.spec.externalName,BROKER:.spec.clusterServiceBrokerName,BINDABLE:.spec.bindable
Copy link
Contributor

Choose a reason for hiding this comment

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

The columns proposed here are good - how able adding plan_updateable?

@@ -27,6 +27,7 @@ import (

// ClusterServiceBroker represents an entity that provides
// ClusterServiceClasses for use in the service catalog.
// +k8s:openapi-gen=x-kubernetes-print-columns:custom-columns=NAME:.metadata.name,URL:.spec.url,STATUS:.status.conditions[*].reason
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure on the formulation of STATUS here, how about remove it and we'll do it in another PR?

@@ -691,6 +695,7 @@ type ServiceBindingList struct {

// ServiceBinding represents a "used by" relationship between an application and an
// ServiceInstance.
// +k8s:openapi-gen=x-kubernetes-print-columns:custom-columns=NAME:.metadata.name,INSTANCE:.spec.instanceRef.name,SECRET:.spec.secretName,STATUS:.status.conditions[*].reason
Copy link
Contributor

Choose a reason for hiding this comment

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

Same concerns about STATUS here.

@luksa
Copy link
Contributor Author

luksa commented Jan 4, 2018

@pmorie Addressed all your comments & rebased to current master

@luksa
Copy link
Contributor Author

luksa commented Jan 4, 2018

/retest

@arschles
Copy link
Contributor

arschles commented Jan 5, 2018

@luksa @pmorie in your opinions, should we wait to merge this until an official kubectl version is out that supports custom columns?

iirc this wouldn't break anything right now so I don't see any problem in merging now

@luksa
Copy link
Contributor Author

luksa commented Jan 6, 2018

This can be merged immediately, as it has no effect until you enable the serving of the OpenAPI schema in the svc cat API server through the --serve-openapi-spec flag (see #1612).

@n3wscott
Copy link
Contributor

LGTM

@kibbles-n-bytes
Copy link
Contributor

I'm happy with this going in.

Copy link
Contributor

@MHBauer MHBauer left a comment

Choose a reason for hiding this comment

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

LGTM

I don't think this could break anything.

@MHBauer MHBauer added the LGTM2 label Feb 6, 2018
@kibbles-n-bytes kibbles-n-bytes merged commit 6d809c3 into kubernetes-retired:master Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. LGTM1 LGTM2 size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants