Update Rust crate kube to v3 #256

Merged
renovate merged 1 commits from renovate/kube-3.x into master 2026-01-14 00:32:32 +00:00
Collaborator

This PR contains the following updates:

Package Type Update Change
kube dependencies major 2.0.13.0.0

Release Notes

kube-rs/kube (kube)

v3.0.0

Compare Source

===================

New Major

As per the new release schedule to match up with the new Kubernetes release.
Lots of additions, fixes and improvements. Thanks to everyone who contributed so heavily over the holidays! Happy new year.

Breaking Changes

Kubernetes v1_35 support via k8s-openapi 0.27

Please upgrade k8s-openapi along with kube to avoid conflicts.

jiff replaces chrono

Matching k8s-openapi's change, kube has also swapped out chrono. The biggest impact of this is for interacting with timestamps in metadata, but it also updates 2 smaller public interfaces in LogParams, Client::with_valid_until. See controller-rs#217 for an example change.

Changes: #​1868 + #​1870

ErrorResponse has been replaced with Status

ErrorResponse served as a partial metav1/Status replacement which ended up hiding error information to users. These structs have merged, more information is available on errors, and a type alias with a deprecation warning is in place for ErrorResponse which will be removed in a later version.

This creates a small breaking change for users matching on specific Error::Api codes;

     .map_err(|error| match error {
-        kube::Error::Api(kube::error::ErrorResponse { code: 403, .. }) => {
-            Error::UnauthorizedToPatch(obj)
-        }
+        kube::Error::Api(s) if s.is_forbidden() => Error::UnauthorizedToPatch(obj),
         other => Error::Other(other),
     })?;

#​1875 + #​1883 + #​1891.

Predicates now has a TTL Cache

This prevents unbounded memory for controllers, particularly affecting ones watching quickly rotating objects with generated names (e.g. pods). By default the TTL is 1h. It can be configured via new PredicateConfig parameter. To use the default;

-        .predicate_filter(predicates::resource_version);
+        .predicate_filter(predicates::resource_version, Default::default());

Change in #​1836. This helped expose and fix a bug in watches with streaming_lists now fixed in #​1882.

Subresource Api

Some subresource write methods were public with inconsistent signatures that required less ergonomic use than any other write methods. They took a Vec<u8> for the post body, now they take a &K: Serialize or the actual subresource.
There affect Api::create_subresource, Api::replace_subresource, Api::replace_status, Api::replace_scale. In essence this generally means you do not have to wrap raw objects in json! and serde_json::to_vec for these calls and lean more on rust's typed objects rather than json! blobs which has some footguns for subresources.

-    let o = foos.replace_status("qux", &pp, serde_json::to_vec(&object)?).await?;
+    let o = foos.replace_status("qux", &pp, &object).await?;

See some more shifts in examples in the implementaion; #​1884

Improvements

Support Kubernetes 1.30 Aggregated Discovery

Speeds up api discovery significantly by using the newer api with much less round-tripping.
To opt-in change Discovery::run() to Discovery::run_aggregated()

Changes; #​1876 + #​1873 + #​1889

Rust 2024

While this is mostly for internal ergonomics, we would like to highlight this also simplifies the Condition implementors which had to deal with a lot of options;

    pub fn is_job_completed() -> impl Condition<Job> {
        |obj: Option<&Job>| {
-            if let Some(job) = &obj {
-                if let Some(s) = &job.status {
-                    if let Some(conds) = &s.conditions {
-                        if let Some(pcond) = conds.iter().find(|c| c.type_ == "Complete") {
-                            return pcond.status == "True";
-                        }
-                    }
-                }
+            if let Some(job) = &obj
+                && let Some(s) = &job.status
+                && let Some(conds) = &s.conditions
+                && let Some(pcond) = conds.iter().find(|c| c.type_ == "Complete")
+            {
+                return pcond.status == "True";

Change #​1856 + #​1792

New Client RetryPolicy opt-in

Allows custom clients (for now) to enable exponential backoff'd retries for retryable errors by exposing a tower::retry::Policy for a tower::retry::Layer. See the new custom_client_retry example for details.

Enabled by a clonable body + the new RetryPolicy based on mirrord's solution*.

Fixes

  • streaming list bug fix - #​1882
  • watcher jitter bug fix - #​1897
  • schema fix for IntOrString - #​1867
  • schema fix for optional enums - #​1853
  • websocket keepalives for long running attaches - #​1889
More
  • Resize subresource impl for Pod - #​1851
  • add #[kube(attr="...") to allow custom attrs on derives - #​1850
  • example updates for admission w/axum - #​1859

What's Changed

Added
Changed
Fixed

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Renovate Bot.

This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [kube](https://github.com/kube-rs/kube) | dependencies | major | `2.0.1` → `3.0.0` | --- ### Release Notes <details> <summary>kube-rs/kube (kube)</summary> ### [`v3.0.0`](https://github.com/kube-rs/kube/blob/HEAD/CHANGELOG.md#300--2026-01-12) [Compare Source](https://github.com/kube-rs/kube/compare/2.0.1...3.0.0) \=================== <!-- Release notes generated using configuration in .github/release.yml at 3.0.0 --> #### New Major As per the new release schedule to match up with the new Kubernetes release. Lots of additions, fixes and improvements. Thanks to everyone who contributed so heavily over the holidays! Happy new year. #### Breaking Changes ##### Kubernetes `v1_35` support via k8s-openapi [0.27](https://github.com/Arnavion/k8s-openapi/releases/tag/v0.27.0) Please [upgrade k8s-openapi along with kube](https://kube.rs/upgrading/) to avoid conflicts. ##### `jiff` replaces `chrono` Matching k8s-openapi's [change](https://github.com/Arnavion/k8s-openapi/commit/8c1b6fccb7258eb487ed8c829791d427a4b16216), kube has also swapped out `chrono`. The biggest impact of this is for interacting with timestamps in `metadata`, but it also updates 2 smaller public interfaces in [`LogParams`](https://docs.rs/kube/latest/kube/api/struct.LogParams.html#structfield.since_time), [`Client::with_valid_until`](https://docs.rs/kube/latest/kube/struct.Client.html#method.with_valid_until). See [controller-rs#217](https://github.com/kube-rs/controller-rs/pull/217/changes) for an example change. Changes: [#&#8203;1868](https://github.com/kube-rs/kube/pull/1868) + [#&#8203;1870](https://github.com/kube-rs/kube/pull/1870) #### `ErrorResponse` has been replaced with [`Status`](https://docs.rs/kube/latest/kube/core/struct.Status.html) `ErrorResponse` served as a partial metav1/Status replacement which ended up hiding error information to users. These structs have merged, more information is available on errors, and a type alias with a deprecation warning is in place for [`ErrorResponse`](https://docs.rs/kube/latest/kube/core/type.ErrorResponse.html) which will be removed in a later version. This creates a small breaking change for users matching on specific [`Error::Api`](https://docs.rs/kube/latest/kube/enum.Error.html#variant.Api) codes; ```diff .map_err(|error| match error { - kube::Error::Api(kube::error::ErrorResponse { code: 403, .. }) => { - Error::UnauthorizedToPatch(obj) - } + kube::Error::Api(s) if s.is_forbidden() => Error::UnauthorizedToPatch(obj), other => Error::Other(other), })?; ``` [#&#8203;1875](https://github.com/kube-rs/kube/pull/1875) + [#&#8203;1883](https://github.com/kube-rs/kube/pull/1883) + [#&#8203;1891](https://github.com/kube-rs/kube/pull/1891). #### Predicates now has a TTL Cache This prevents unbounded memory for controllers, particularly affecting ones watching quickly rotating objects with generated names (e.g. pods). By default the TTL is `1h`. It can be configured via new [`PredicateConfig`](https://docs.rs/kube/latest/kube/runtime/struct.PredicateConfig.html) parameter. To use the default; ```diff - .predicate_filter(predicates::resource_version); + .predicate_filter(predicates::resource_version, Default::default()); ``` Change in [#&#8203;1836](https://github.com/kube-rs/kube/pull/1836). This helped expose and fix a bug in watches with streaming\_lists now fixed in [#&#8203;1882](https://github.com/kube-rs/kube/pull/1882). #### Subresource Api Some subresource write methods were public with inconsistent signatures that required less ergonomic use than any other write methods. They took a `Vec<u8>` for the post body, now they take a `&K: Serialize` or the actual subresource. There affect `Api::create_subresource`, `Api::replace_subresource`, [`Api::replace_status`](https://docs.rs/kube/latest/kube/struct.Api.html#method.replace_status), `Api::replace_scale`. In essence this generally means you do not have to wrap raw objects in `json!` and `serde_json::to_vec` for these calls and lean more on rust's typed objects rather than `json!` blobs which has some [footguns](https://github.com/kube-rs/kube/pull/1884#discussion_r2680782556) for subresources. ```diff - let o = foos.replace_status("qux", &pp, serde_json::to_vec(&object)?).await?; + let o = foos.replace_status("qux", &pp, &object).await?; ``` See some more shifts in examples in the implementaion; [#&#8203;1884](https://github.com/kube-rs/kube/pull/1884) #### Improvements ##### Support Kubernetes 1.30 [Aggregated Discovery](https://kubernetes.io/docs/concepts/overview/kubernetes-api/#aggregated-discovery) Speeds up api discovery **significantly** by using the newer api with much less round-tripping. To opt-in change `Discovery::run()` to [`Discovery::run_aggregated()`](https://docs.rs/kube/latest/kube/struct.Discovery.html#method.run_aggregated) Changes; [#&#8203;1876](https://github.com/kube-rs/kube/pull/1876) + [#&#8203;1873](https://github.com/kube-rs/kube/pull/1873) + [#&#8203;1889](https://github.com/kube-rs/kube/pull/1889) ##### Rust 2024 While this is mostly for internal ergonomics, we would like to highlight this also simplifies the [`Condition`](https://docs.rs/kube/latest/kube/runtime/wait/conditions/trait.Condition.html) implementors which had to deal with a lot of options; ```diff pub fn is_job_completed() -> impl Condition<Job> { |obj: Option<&Job>| { - if let Some(job) = &obj { - if let Some(s) = &job.status { - if let Some(conds) = &s.conditions { - if let Some(pcond) = conds.iter().find(|c| c.type_ == "Complete") { - return pcond.status == "True"; - } - } - } + if let Some(job) = &obj + && let Some(s) = &job.status + && let Some(conds) = &s.conditions + && let Some(pcond) = conds.iter().find(|c| c.type_ == "Complete") + { + return pcond.status == "True"; ``` Change [#&#8203;1856](https://github.com/kube-rs/kube/pull/1856) + [#&#8203;1792](https://github.com/kube-rs/kube/pull/1792) ##### New Client [`RetryPolicy`](https://docs.rs/kube/latest/kube/client/retry/struct.RetryPolicy.html) opt-in Allows custom clients (for now) to enable exponential backoff'd retries for retryable errors by exposing a [`tower::retry::Policy`](https://tower-rs.github.io/tower/tower/retry/trait.Policy.html) for a [`tower::retry::Layer`](https://tower-rs.github.io/tower/tower/retry/struct.RetryLayer.html). See the new [custom\_client\_retry](https://github.com/kube-rs/kube/blob/main/examples/custom_client_retry.rs#L24-L37) example for details. Enabled by a [clonable body](https://github.com/kube-rs/kube/pull/1867) + the new [RetryPolicy](https://github.com/kube-rs/kube/pull/1894) based on mirrord's solution[\*](https://github.com/metalbear-co/mirrord/blob/a9e4c52a720fd5a833e30aee1ac650360031b7a7/mirrord/kube/src/retry.rs#L41-L135). #### Fixes - streaming list bug fix - [#&#8203;1882](https://github.com/kube-rs/kube/pull/1882) - watcher jitter bug fix - [#&#8203;1897](https://github.com/kube-rs/kube/pull/1897) - schema fix for IntOrString - [#&#8203;1867](https://github.com/kube-rs/kube/pull/1867) - schema fix for optional enums - [#&#8203;1853](https://github.com/kube-rs/kube/pull/1853) - websocket keepalives for long running attaches - [#&#8203;1889](https://github.com/kube-rs/kube/pull/1889) ##### More - `Resize` subresource impl for `Pod` - [#&#8203;1851](https://github.com/kube-rs/kube/pull/1851) - add `#[kube(attr="...")` to allow custom attrs on derives - [#&#8203;1850](https://github.com/kube-rs/kube/pull/1850) - example updates for admission w/axum - [#&#8203;1859](https://github.com/kube-rs/kube/pull/1859) #### What's Changed ##### Added - Add `Resize` subresource for `Pod` by [@&#8203;hugoponthieu](https://github.com/hugoponthieu) in [#&#8203;1851](https://github.com/kube-rs/kube/pull/1851) - feat: add #\[kube(attr="...")] attribute helper to set attribute helper on the CR root type by [@&#8203;ngergs](https://github.com/ngergs) in [#&#8203;1850](https://github.com/kube-rs/kube/pull/1850) - Rust 2024 let-chains to simplify wait Conditions by [@&#8203;clux](https://github.com/clux) in [#&#8203;1792](https://github.com/kube-rs/kube/pull/1792) - Adds a `try_clone` method for `kube_client::client::Body` when it's `Kind::Once` by [@&#8203;meowjesty](https://github.com/meowjesty) in [#&#8203;1867](https://github.com/kube-rs/kube/pull/1867) - Implement client aggregated discovery API methods by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1873](https://github.com/kube-rs/kube/pull/1873) - Implement aggregated discovery API methods by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1876](https://github.com/kube-rs/kube/pull/1876) - Permit older version of API for v2 discovery for k8s < 1.30 (down to 1.27) by [@&#8203;Danil-Grigorev](https://github.com/Danil-Grigorev) in [#&#8203;1889](https://github.com/kube-rs/kube/pull/1889) - Add RetryPolicy for client-level request retries by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1894](https://github.com/kube-rs/kube/pull/1894) ##### Changed - Update tokio-tungstenite requirement from 0.27.0 to 0.28.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;1829](https://github.com/kube-rs/kube/pull/1829) - Predicates: add configurable cache TTL for `predicate_filter` by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1838](https://github.com/kube-rs/kube/pull/1838) - Update darling requirement from 0.21.0 to 0.23.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;1861](https://github.com/kube-rs/kube/pull/1861) - update to jsonpath-rust 1 by [@&#8203;tottoto](https://github.com/tottoto) in [#&#8203;1863](https://github.com/kube-rs/kube/pull/1863) - Replace `chrono` with `jiff` by [@&#8203;ngergs](https://github.com/ngergs) in [#&#8203;1868](https://github.com/kube-rs/kube/pull/1868) - Merge ErrorResponse and Status by [@&#8203;imp](https://github.com/imp) in [#&#8203;1875](https://github.com/kube-rs/kube/pull/1875) - Make subresource methods more ergonomic by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1884](https://github.com/kube-rs/kube/pull/1884) - Drop k8s v1.30, crono->jiff replacement for runtime & examples by [@&#8203;ngergs](https://github.com/ngergs) in [#&#8203;1870](https://github.com/kube-rs/kube/pull/1870) - Add a metadata field to Status by [@&#8203;ryanpbrewster](https://github.com/ryanpbrewster) in [#&#8203;1891](https://github.com/kube-rs/kube/pull/1891) - Bump `k8s-openapi` for Kubernetes 1.35 by [@&#8203;clux](https://github.com/clux) in [#&#8203;1898](https://github.com/kube-rs/kube/pull/1898) ##### Fixed - fix: add use<> to kubelet\_node\_logs for rust edition 2024 by [@&#8203;co42](https://github.com/co42) in [#&#8203;1849](https://github.com/kube-rs/kube/pull/1849) - Transform optional enums to match pre kube 2.0.0 format by [@&#8203;Danil-Grigorev](https://github.com/Danil-Grigorev) in [#&#8203;1853](https://github.com/kube-rs/kube/pull/1853) - Distinguish between initial and resumed watch phases for streaming lists by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1882](https://github.com/kube-rs/kube/pull/1882) - Re-export deprecated type alias and improve deprecation guidance by [@&#8203;clux](https://github.com/clux) in [#&#8203;1883](https://github.com/kube-rs/kube/pull/1883) - Add nullable to optional fields with x-kubernetes-int-or-string by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1885](https://github.com/kube-rs/kube/pull/1885) - send websocket ping to keep idle connections alive by [@&#8203;inqode-lars](https://github.com/inqode-lars) in [#&#8203;1887](https://github.com/kube-rs/kube/pull/1887) - Fix watcher ExponentialBackoff jitter ignored by [@&#8203;doxxx93](https://github.com/doxxx93) in [#&#8203;1897](https://github.com/kube-rs/kube/pull/1897) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MS4xIiwidXBkYXRlZEluVmVyIjoiNDIuODEuMSIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6W119-->
renovate added 1 commit 2026-01-14 00:32:27 +00:00
Update Rust crate kube to v3
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
bc108a6ccb
renovate scheduled this pull request to auto merge when all checks succeed 2026-01-14 00:32:29 +00:00
renovate merged commit 3d3aacff62 into master 2026-01-14 00:32:32 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: pierre/MinioK8sBuckets#256