Skip to content

Using this crate requires pinning kube-rs and k8s-openapi versions and the k8s-openapi v1_29 featureΒ #46

@blinsay

Description

@blinsay

I'm trying to use this crate in a project with more recent versions of kube-rs and k8s-openapi and it's proving pretty difficult because of pinned dependency versions. This looks like it was discussed and fixed in #2 and then regressed at some point (edit: looks like it changed in #30).

Long repro below, but I'd love to not have to worry about what versions of those dependencies this crate picks.


This is easy to reproduce in a brand new project, using the following main.rs.

#[tokio::main]
async fn main() {
    let client = kube::Client::try_default().await.unwrap();
    let api: kube::Api<gateway_api::apis::standard::httproutes::HTTPRoute> = kube::Api::all(client);
}

If I use my own version of those dependencies the types declared here don't implement Resource because of a version mismatch between the two versions of kube-rs and k8s-openapi getting pulled into the dependency graph:

[dependencies]
gateway-api = "0.10"
k8s-openapi = { version = "0.22", features = ["v1_29"] }
kube = { version = "0.92", features = ["runtime", "client", "derive"] }
tokio = { version = "1.38", features = ["full"] }
) $ cargo run
   Compiling kube-client v0.92.1
   Compiling kube-runtime v0.92.1
   Compiling kube v0.92.1
   Compiling api-gateway-example v0.1.0 (/Users/benl/src/scratch/api-gateway-example)
error[E0277]: the trait bound `gateway_api::apis::standard::httproutes::HTTPRoute: k8s_openapi::_resource::Metadata` is not satisfied
 --> src/main.rs:4:78
  |
4 |     let api: kube::Api<gateway_api::apis::standard::httproutes::HTTPRoute> = kube::Api::all(client);
  |                                                                              ^^^^^^^^^^^^^^^^^^^^^^ the trait `k8s_openapi::_resource::Metadata` is not implemented for `gateway_api::apis::standard::httproutes::HTTPRoute`, which is required by `gateway_api::apis::standard::httproutes::HTTPRoute: Resource`
  |
...

If I try to use a newer version of kube-rs, it pulls in a newer version of k8s-openapi on its own with no v1_* feature set, and fails to compile.

[dependencies]
gateway-api = "0.10"
k8s-openapi = { version = "0.21.1", features = ["v1_29"] }
kube = { version = "0.92", features = ["runtime", "client", "derive"] }
tokio = { version = "1.38", features = ["full"] }
error: failed to run custom build command for `k8s-openapi v0.22.0`

Caused by:
  process didn't exit successfully: `/Users/benl/src/scratch/api-gateway-example/target/debug/build/k8s-openapi-2ab36a4643e1e386/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=K8S_OPENAPI_ENABLED_VERSION

  --- stderr
  thread 'main' panicked at /Users/benl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/k8s-openapi-0.22.0/build.rs:17:42:

  None of the v1_* features are enabled on the k8s-openapi crate.

  The k8s-openapi crate requires a feature to be enabled to indicate which version of Kubernetes it should support.
...

Finally, if I try to use exactly the versions of those libraries this dependency wants, I'm unable to use a version other than v1_29.

[dependencies]
gateway-api = "0.10"
k8s-openapi = { version = "0.21.1", features = ["v1_28"] }
kube = { version = "0.88.1", features = ["runtime", "client", "derive"] }
tokio = { version = "1.38", features = ["full"] }
$ cargo run
   Compiling k8s-openapi v0.21.1
error: failed to run custom build command for `k8s-openapi v0.21.1`

Caused by:
  process didn't exit successfully: `/Users/benl/src/scratch/api-gateway-example/target/debug/build/k8s-openapi-bc80d41dae7db53e/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=K8S_OPENAPI_ENABLED_VERSION

  --- stderr
  thread 'main' panicked at /Users/benl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/k8s-openapi-0.21.1/build.rs:45:13:

  Both v1_28 and v1_29 features are enabled on the k8s-openapi crate. These feature indicates which version of Kubernetes the k8s-openapi crate should support. Only one feature can be enabled at the same time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedA community volunteer to work on this is wanted.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions