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

dealing with CRDs? #7

Open
clux opened this issue Nov 14, 2018 · 5 comments
Open

dealing with CRDs? #7

clux opened this issue Nov 14, 2018 · 5 comments

Comments

@clux
Copy link
Contributor

clux commented Nov 14, 2018

The API for CRDs is generated by kube as soon as the CRD is posted. Thus these structs are not normally available in the openapi bindings or something else (the crd might not even have a schema in older versions of kube). This is usually not a problem, because if you're using rust, you might have a more precise struct for this anyway, but it would be nice to have an API wrapper for this call somehow maybe?

The go toolchain does some awkward codegeneration that they force people to do more-or-less manually, but that shouldn't be necessary when you have serde and rust on your side. Still, not sure what's the best way to tackle this.

Currently, am just calling the api the easy way:
https://github.com/Babylonpartners/shipcat/blob/8e1fd9c1e0bfef1a9f642f9d7d64b1b938f00ae2/raftcat/src/kube.rs#L13-L19
(and thus avoiding the openapi bindings entirely because that's all i need atm)
but wondered if you/someone had thoughts on this.

@ynqa
Copy link
Owner

ynqa commented Nov 15, 2018

@clux Thanks also.

Firstly I tried to use generated codes by swagger-codegen/openapi-generator and not to edit them as possible. Because it's difficult to trace and maintain k8s APIs each version.

However, there are a lot of bugs on swagger codes. Therefore, I've adapted to use 3rdparty generators for requests (after all, this maintains swagger codes with sed-like operations).

Since it has ended up such results, I'm considering whether to manage APIs (including CRD you pointed out) also for kubernetes or not.

@clux
Copy link
Contributor Author

clux commented Nov 21, 2018

Ah, and you've switched to using hyper directly. I only saw that just now :<

@ynqa
Copy link
Owner

ynqa commented Nov 27, 2018

@clux Yes, but it's also not so good for tackling #6 issue. I'm considering to define APIs on my own codes.

@clux
Copy link
Contributor Author

clux commented Apr 28, 2019

I've been trying to tackle this directly.

Have written an implementation of a reflector: https://github.com/clux/kubernetes-rust/blob/master/src/api/reflector.rs - to mimic what people do with client-go.

This allows us to write kubernetes operators by doing stuff like: https://github.com/clux/operator-rs

Tried to go down the k8s-openapi route, but the calls for instances of CRDs just weren't there. And even if they were there, the hardest part is writing some stuff that synchronises it.

How do you feel about maybe having crate for all the stuff for the kube config, and one config for extras?

@ynqa
Copy link
Owner

ynqa commented May 10, 2019

svend pushed a commit to svend/kubernetes-rust that referenced this issue Jul 26, 2019
slight restructuring as well, but nothing major.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants