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.
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),
})?;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
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*.
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";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
Resizesubresource impl forPod- #1851- add
#[kube(attr="...")to allow custom attrs on derives - #1850 - example updates for admission w/axum - #1859
What's Changed
Added
- Add
Resizesubresource forPodby @hugoponthieu in #1851 - feat: add #[kube(attr="...")] attribute helper to set attribute helper on the CR root type by @ngergs in #1850
- Rust 2024 let-chains to simplify wait Conditions by @clux in #1792
- Adds a
try_clonemethod forkube_client::client::Bodywhen it'sKind::Onceby @meowjesty in #1867 - Implement client aggregated discovery API methods by @doxxx93 in #1873
- Implement aggregated discovery API methods by @doxxx93 in #1876
- Permit older version of API for v2 discovery for k8s < 1.30 (down to 1.27) by @Danil-Grigorev in #1889
- Add RetryPolicy for client-level request retries by @doxxx93 in #1894
Changed
- Update tokio-tungstenite requirement from 0.27.0 to 0.28.0 by @dependabot[bot] in #1829
- Predicates: add configurable cache TTL for
predicate_filterby @doxxx93 in #1838 - Update darling requirement from 0.21.0 to 0.23.0 by @dependabot[bot] in #1861
- update to jsonpath-rust 1 by @tottoto in #1863
- Replace
chronowithjiffby @ngergs in #1868 - Merge ErrorResponse and Status by @imp in #1875
- Make subresource methods more ergonomic by @doxxx93 in #1884
- Drop k8s v1.30, crono->jiff replacement for runtime & examples by @ngergs in #1870
- Add a metadata field to Status by @ryanpbrewster in #1891
- Bump
k8s-openapifor Kubernetes 1.35 by @clux in #1898
Fixed
- fix: add use<> to kubelet_node_logs for rust edition 2024 by @co42 in #1849
- Transform optional enums to match pre kube 2.0.0 format by @Danil-Grigorev in #1853
- Distinguish between initial and resumed watch phases for streaming lists by @doxxx93 in #1882
- Re-export deprecated type alias and improve deprecation guidance by @clux in #1883
- Add nullable to optional fields with x-kubernetes-int-or-string by @doxxx93 in #1885
- send websocket ping to keep idle connections alive by @inqode-lars in #1887
- Fix watcher ExponentialBackoff jitter ignored by @doxxx93 in #1897
New Contributors
- @doxxx93 made their first contribution in #1836
- @elisaado made their first contribution in #1845
- @hugoponthieu made their first contribution in #1851
- @ngergs made their first contribution in #1850
- @meowjesty made their first contribution in #1867
- @inqode-lars made their first contribution in #1887
- @ryanpbrewster made their first contribution in #1891
- @uchiha-vivek made their first contribution in #1895
Full Changelog: 2.0.1...3.0.0