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

Create APIResource from ApiResource for extension an APIService #1194

Open
clux opened this issue Apr 8, 2023 · 1 comment
Open

Create APIResource from ApiResource for extension an APIService #1194

clux opened this issue Apr 8, 2023 · 1 comment
Labels
blocked awaiting upstream work core generic apimachinery style work

Comments

@clux
Copy link
Member

clux commented Apr 8, 2023

What problem are you trying to solve?

Reading this blog post:
https://metalbear.co/blog/writing-a-kubernetes-operator/
on how to set up an extension apiservice with kube, most of how this is done looks reasonably easy.

However, there's awkward step where it's necessary to convert our Resource to an APIResource.
That bit is basically what you see in their source here:
https://github.com/metalbear-co/farm-operator/blob/f7ae23f61daff4bdc9b9063796bc49057c20e914/example/step-3/src/main.rs#L14-L36

i.e. manually converting between the two:

APIResource {
    group: Some(llama::Llama::group(&()).into()),
    kind: llama::Llama::kind(&()).into(),
    name: llama::Llama::plural(&()).into(),
    namespaced: true,
    verbs: vec!["list".to_string(), "get".to_string()],
    ..Default::default()
},

This came up in kube-rs/website#34 (comment)

Describe the solution you'd like

The example above is converting using the Resource trait, but that is actually insufficient (hence the manually supplied verbs).

The only place that has all that information for us is the ApiResource.

This feels like a simple Into<APIResource> for ApiResource impl.

If anyone wants to do this, it should be an easy one.

Note that CRD users via kube-derive will have access to their own ApiResource without going through discovery (which crucially they can't do as they are the apiserver for this resource) by using CustomResourceExt::api_resource. So from there, a converter will fill in the rest.

Target crate for feature

kube-core

@clux clux added help wanted Not immediately prioritised, please help! good first issue Good for newcomers core generic apimachinery style work labels Apr 8, 2023
@clux clux changed the title Simplify creation of APIResource from Resource for extension an APIService Create APIResource from ApiResource for extension an APIService Apr 8, 2023
@clux clux linked a pull request Apr 9, 2023 that will close this issue
@clux clux removed the good first issue Good for newcomers label Apr 9, 2023
@clux
Copy link
Member Author

clux commented Apr 9, 2023

Turns out we can't do this cleanly yet because we'd actually need to do that into impl from the pair (ApiResource, ApiCapabilities).

There is an ongoing (but bitrotted) PR that aims to consolidate these structs, but need to fix that up first.

@clux clux added blocked awaiting upstream work and removed help wanted Not immediately prioritised, please help! labels Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked awaiting upstream work core generic apimachinery style work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant