Giter Site home page Giter Site logo

Comments (7)

alexec avatar alexec commented on September 17, 2024 1

Reading comments on bug was key in helping me solve my own bug. Thank you.

from kube-openapi.

sttts avatar sttts commented on September 17, 2024

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.

michaeljmarshall avatar michaeljmarshall commented on September 17, 2024

@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.

sttts avatar sttts commented on September 17, 2024

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.

michaeljmarshall avatar michaeljmarshall commented on September 17, 2024

@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.

sttts avatar sttts commented on September 17, 2024

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.

michaeljmarshall avatar michaeljmarshall commented on September 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.