Comments (7)
Reading comments on bug was key in helping me solve my own bug. Thank you.
from kube-openapi.
Are you trying to generate the spec for a CRD? Then better use kubebuilder's controller-tools, e.g. the schemapatch
command (https://github.com/kubernetes-sigs/controller-tools/blob/master/cmd/controller-gen/main.go#L140).
I would consider the openapi generator here deprecated and only to be used for the very specific use-case of aggregated API servers.
from kube-openapi.
@sttts -- thanks for your insight here. I didn't realize the limited scope of this generator. I have a SparkApplication
CRD that is defined in the spark-on-k8s-operator repo. My end goal is to generate a Java client that knows about the CRDs defined in that project so that I can introduce type safety as well as make it easier to handle updates to the spark operator project. After searching through various projects, I had thought I would need to use this project to generate the go code (modules?) that I could then use to generate the openapi-spec json file. I thought I'd need an output similar to the one found in the kubernetes
project found here, and then I'd use the json file as the input to the kubernetes-client/gen project. Are you saying there is another way to make the openapi-spec json file for use by the client gen project? Or are you saying I can use the resulting yaml file from the controller-tools
command to build the Java client?
from kube-openapi.
https://github.com/kubernetes-sigs/controller-tools/blob/master/cmd/controller-gen/main.go#L140 will give you a schema in your CRD manifest. Create that in a cluster and download the OpenAPI spec from the cluster: kubectl get --raw /openapi/v2
. That should do it for client generators.
from kube-openapi.
@sttts - I am not sure I am following you. It seems inverted to me that I'd need to inspect my kubernetes cluster in order to get an OpenApi spec for a well defined CRD. There should be a way to generate an OpenApi spec that I could then use to generate a client library containing the data models for that CRD. I'd use the generate CRD code as a library to simplify serialization and deserialization of the objects when calling the CustomObjectsApi
.
I opened this issue because I was able to generate the OpenApi spec using this project along with my minor change (described above) to the k8s InternalEvent
type defined in the k8s apimachinery package. From the OpenApi spec, I was able to generate a client library containing the classes for the CRD. (I used this project https://github.com/kubernetes-client/gen to generate the client.)
From my perspective, this project seems capable of generating a valid OpenApi spec that could be used to generate data models that align with CRDs.
from kube-openapi.
It might partly work now, but is no supported use-case of openapi-gen and it won't be extended towards CRDs. The spec is incomplete and also partly wrong (AFAIK, int-or-string is not generated correctly, maybe other types too).
from kube-openapi.
It surprises me that there isn't an easy way to generate library definitions for CRDs. Thank you for the additional context and help here.
from kube-openapi.
Related Issues (20)
- How to specify a default? HOT 6
- Build fails due to `undefined: atomic.Pointer` HOT 7
- Feature request: Tagged releases HOT 11
- Generated enum fails validation when used for CRD creation HOT 15
- Request to remove reference to deprecated module 'github.com/golang/protobuf HOT 8
- [Umbrella Issue] Caching library improvements HOT 8
- Change breaks client-go: gnostic -> gnostic-models HOT 7
- [Discussion] Compatibility Guarantees and Versioning HOT 10
- Validator for `byte` does not match mashalling behavior HOT 16
- Generating openAPIV3Schema YAML file HOT 1
- OpenAPI V3 specifications do not mark requestBody as "required" HOT 2
- [Bug] The latest main branch will conflict with k8s [email protected] HOT 2
- Bug: +enum type used in array is not reflected in Schema
- Bugs from recent changes - go.mod version invalid for go 1.20 and new interface is missing input -i HOT 11
- Add presubmit check to prevent accidental `go` directive bump HOT 1
- Please upgrade mergo HOT 1
- OpenAPI V3 references parsed as *proto.Arbitrary instead of *proto.Ref HOT 2
- Fix FilterSpecByPathsWithoutSideEffects to handle cases without slash HOT 2
- kube-openapi tests fail at newer versions of go HOT 7
- Recent changes break escapes in quoted strings HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kube-openapi.