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

Generate openapi spec for CRD objects #1231

Closed
gclawes opened this issue Dec 1, 2019 · 16 comments
Closed

Generate openapi spec for CRD objects #1231

gclawes opened this issue Dec 1, 2019 · 16 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@gclawes
Copy link

gclawes commented Dec 1, 2019

Provide a way to generate OpenAPI specs for the CRDs generated by kubebuilder. It would be useful to be able to generate API libraries for CRD objects in languages other than go.

A specific use case is where the controller for a CRD is written in go, but tools that generate Custom Resource configurations are written in other languages that OpenAPI can generate libraries for (Python, Java, Ruby, Bash, etc). This is especially useful when such applications are already using the OpenAPI-generated kubernetes libraries (kubernetes-client/*).

This issue was started based on a discussion in #1129

This does not require a specific kubernetes version.

/kind feature

@gclawes gclawes added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 1, 2019
@DirectXMan12
Copy link
Contributor

That's what controller-tools already generates OpenAPI data for CRDs as part of generating the CRD validation schema. Is that not sufficient?

@gclawes
Copy link
Author

gclawes commented Dec 16, 2019

I haven't been able to find any documentation on that, could you point me in the right direction?

@RedbackThomson
Copy link

That's what controller-tools already generates OpenAPI data for CRDs as part of generating the CRD validation schema. Is that not sufficient?

I see the OpenAPI embedded as validation. Are you suggesting this is a fully functional OpenAPI spec itself? Is there any way to output these into its own spec file rather than having to extract it?

@DirectXMan12
Copy link
Contributor

I see the OpenAPI embedded as validation. Are you suggesting this is a fully functional OpenAPI spec itself?

Yes, more or less. The Kubernetes API server is free to change it in ways that we don't have control over/can't (e.g. it substitutes the top-level ObjectMeta for the current server's ObjectMeta), but the validation spec is a valid and (almost) complete OpenAPI spec.

Is there any way to output these into its own spec file rather than having to extract it?

As of now, there's no way to generate it into a separate file, but we could add that. In the mean time (if this is really pressing), you should be able to consume that part of controller-tools as a library.

However, you're slightly better off pulling it from the live API server if you're really concerned with full correctness (see above).

@RedbackThomson
Copy link

As of now, there's no way to generate it into a separate file, but we could add that

I could see this being a very valuable feature for operator clients who intend for others to consume their CRDs from third-party clients (or wrappers). It's not pressing for us at the moment, but would love to see this on the road map at some point.

you're slightly better off pulling it from the live API server

We would like to consume it at compile-time and also to produce CRD documentation, so sadly this isn't an option.

@gclawes
Copy link
Author

gclawes commented Jan 7, 2020

I could see this being a very valuable feature for operator clients who intend for others to consume their CRDs from third-party clients (or wrappers).

This is the use case I'm after. Create CRDs and operators using kubebuilder, but generate client libraries in languages other than go.

@DirectXMan12
Copy link
Contributor

/help

@k8s-ci-robot
Copy link
Contributor

@DirectXMan12:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jan 7, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 6, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 6, 2020
@gclawes
Copy link
Author

gclawes commented May 15, 2020

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label May 15, 2020
@gclawes
Copy link
Author

gclawes commented Jul 6, 2020

Is it possible to revisit this?

@vincepri
Copy link
Member

We could add a new generator to controller-tools that given some paths to api folder, it generates OpenAPI spec files using the content that's today under openAPIV3Schema

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 21, 2020
@camilamacedo86 camilamacedo86 added this to the next milestone Nov 3, 2020
@camilamacedo86 camilamacedo86 removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 3, 2020
@camilamacedo86 camilamacedo86 modified the milestones: next, v3+ plugin Nov 3, 2020
@estroz
Copy link
Contributor

estroz commented Nov 17, 2020

This feature request is specific to controller-gen and not necessarily something kubebuilder needs to know about until it is implemented there. I suggest this is closed here and re-opened in controller-tools.

/close

@k8s-ci-robot
Copy link
Contributor

@estroz: Closing this issue.

In response to this:

This feature request is specific to controller-gen and not necessarily something kubebuilder needs to know about until it is implemented there. I suggest this is closed here and re-opened in controller-tools.

/close

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

8 participants