Skip to content

Commit

Permalink
Merge branch 'main' into client-core-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
clux authored Feb 12, 2023
2 parents ab7841f + 43e6875 commit 5d61922
Show file tree
Hide file tree
Showing 78 changed files with 1,912 additions and 711 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# Includes workaround for macos cache corruption.
# - https://github.com/rust-lang/cargo/issues/8603
# - https://github.com/actions/cache/issues/403
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

# Install OpenSSL Libraries for Windows
- name: install openssl
Expand Down Expand Up @@ -55,9 +55,6 @@ jobs:
run: cargo build -j4 -p kube-examples

# Feature tests
- name: Test kube with features native-tls,ws,oauth
run: cargo test -p kube --lib --no-default-features --features=native-tls,ws,oauth
if: matrix.os == 'ubuntu-latest'
- name: Test kube with features rustls-tls,ws,oauth
run: cargo test -p kube --lib --no-default-features --features=rustls-tls,ws,oauth
if: matrix.os == 'ubuntu-latest'
Expand Down Expand Up @@ -85,7 +82,7 @@ jobs:
toolchain: ${{ steps.msrv.outputs.msrv }}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
- name: Check
uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -122,7 +119,7 @@ jobs:
fail-fast: false
matrix:
# Run these tests against older clusters as well
k8s: [v1.20, latest]
k8s: [v1.21, latest]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -134,7 +131,7 @@ jobs:
# Includes workaround for macos cache corruption.
# - https://github.com/rust-lang/cargo/issues/8603
# - https://github.com/actions/cache/issues/403
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

- uses: nolar/setup-k3d-k3s@v1
with:
Expand Down Expand Up @@ -198,11 +195,11 @@ jobs:
# Includes workaround for macos cache corruption.
# - https://github.com/rust-lang/cargo/issues/8603
# - https://github.com/actions/cache/issues/403
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

- uses: nolar/setup-k3d-k3s@v1
with:
version: v1.20
version: v1.21
# k3d-kube
k3d-name: kube
# Used to avoid rate limits when fetching the releases from k3s repo.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
- uses: AbsaOSS/k3d-action@v2
name: "Create Single Cluster"
with:
Expand Down
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Eirik A <sszynrae@gmail.com> <sszynrae@gmail.com>
87 changes: 85 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,90 @@
<!-- next-header -->
UNRELEASED
===================
* see https://github.com/kube-rs/kube/compare/0.75.0...main
* see https://github.com/kube-rs/kube/compare/0.78.0...main

[0.78.0](https://github.com/kube-rs/kube/releases/tag/0.78.0) / 2023-01-06
===================
<!-- Release notes generated using configuration in .github/release.yml at 0.78.0 -->

## Kubernetes Bump

This release brings in the new [`k8s-openapi` release](https://github.com/Arnavion/k8s-openapi/releases/tag/v0.17.0) for `1.26` structs, and sets our [MK8SV](https://kube.rs/kubernetes-version/) to `1.21`.
Be sure to upgrade `k8s-openapi` and `kube` **simultaneously** to avoid multiple version errors:

```sh
cargo upgrade -p k8s-openapi -p kube -i
```

## What's Changed
### Added
* reflector: add helper function to the `Store` by @eliad-wiz in https://github.com/kube-rs/kube/pull/1111
### Changed
* Bump `k8s-openapi@0.17.0` and MK8SV by @clux in https://github.com/kube-rs/kube/pull/1116
### Removed
* Remove deprecated `Config::timeout` by @clux in https://github.com/kube-rs/kube/pull/1113
### Fixed
* fix shell exec exiting message loop when terminalSizeReceiver is dropped by @erebe in https://github.com/kube-rs/kube/pull/1112

[0.77.0](https://github.com/kube-rs/kube/releases/tag/0.77.0) / 2022-12-15
===================
<!-- Release notes generated using configuration in .github/release.yml at 0.77.0 -->
## Highlights

This release saw numerous improvements across various parts of the codebase with lots of help from external contributors. Look for improvements in error handling, client exec behaviour, dynamic object conversion, certificate handling, and last, but not least; lots of enhancements in the `config` module. Huge thanks to everyone who contributed!

### `Config` Enhancements
Kubeconfigs relying on [`ExecConfig`](https://docs.rs/kube/0.77.0/kube/config/struct.ExecConfig.html) for auth should now work with a lot more cases (with improvements to script interactivity, cert passing, env-drop, and windows behaviour). We further aligned our [`Kubeconfig`](https://docs.rs/kube/0.77.0/kube/config/struct.Kubeconfig.html) parsing with client-go's behaviour, and also exposed [`Kubeconfig::merge`](https://docs.rs/kube/0.77.0/kube/config/struct.Kubeconfig.html#method.merge). Finally, we now pass [`Config::tls_server_name`](https://docs.rs/kube/0.77.0/kube/struct.Config.html#structfield.tls_server_name) through to the `Client`, which has let us include [a better **rustls** workaround](https://docs.rs/kube/0.77.0/kube/struct.Config.html#method.incluster) for the long-standing ip issue (enabled by default).

## What's Changed
### Added
* Add `DynamicObjects::try_parse` for typed object conversion by @jmintb in https://github.com/kube-rs/kube/pull/1061
* Add `ExecConfig::drop_env` to filter host evars for auth providers by @aviramha in https://github.com/kube-rs/kube/pull/1062
* Add support for terminal size when executing command inside a container by @armandpicard in https://github.com/kube-rs/kube/pull/983
* add cmd-drop-env to AuthProviderConfig by @aviramha in https://github.com/kube-rs/kube/pull/1074
* Check for client cert with exec by @rcanderson23 in https://github.com/kube-rs/kube/pull/1089
* Change `Kubeconfig::merge` fn to public. by @goenning in https://github.com/kube-rs/kube/pull/1100
* Fix interactivity in auth exec by @armandpicard in https://github.com/kube-rs/kube/pull/1083
### Changed
* [windows] skip window creation on auth exec by @goenning in https://github.com/kube-rs/kube/pull/1095
* Add `Config::tls_server_name` and validate when using rustls by @clux in https://github.com/kube-rs/kube/pull/1104
### Removed
* Remove deprecated `ResourceExt::name` by @clux in https://github.com/kube-rs/kube/pull/1105
### Fixed
* Bump tracing dependency to 0.1.36 by @teozkr in https://github.com/kube-rs/kube/pull/1070
* Improve error message on azure auth not being supported by @goenning in https://github.com/kube-rs/kube/pull/1082
* exec: ensure certs always end with a new line by @goenning in https://github.com/kube-rs/kube/pull/1096
* fix: align kube-rs with client-go config parsing by @goenning in https://github.com/kube-rs/kube/pull/1077
* Return error from `watcher` when kinds do not support watch by @clux in https://github.com/kube-rs/kube/pull/1101

[0.76.0](https://github.com/kube-rs/kube/releases/tag/0.76.0) / 2022-10-28
===================
<!-- Release notes generated using configuration in .github/release.yml at 0.76.0 -->

## Highlights

### [`#[derive(CustomResource)]` now supports schemas with untagged enums](https://github.com/kube-rs/kube/pull/1028)

Expanding on our existing support for storing Rust's struct enums in CRDs, Kube will now try to convert `#[serde(untagged)]` enums as well. Note that if the same field is present in multiple untagged variants then they must all have the same shape.

### [Removed deprecated `try_flatten_*` functions](https://github.com/kube-rs/kube/pull/1019)

These have been deprecated since 0.72, and are replaced by the equivalent `WatchStreamExt` methods.

## What's Changed
### Added
* Adds example to `Controller::watches` by @Dav1dde in https://github.com/kube-rs/kube/pull/1026
* Discovery: Add `ApiGroup::resources_by_stability` by @imuxin in https://github.com/kube-rs/kube/pull/1022
* Add support for untagged enums in CRDs by @sbernauer in https://github.com/kube-rs/kube/pull/1028
* Derive PartialEq for DynamicObject by @pbzweihander in https://github.com/kube-rs/kube/pull/1048
### Removed
* Runtime: Remove deprecated util `try_flatten_` helpers by @clux in https://github.com/kube-rs/kube/pull/1019
* Remove `native-tls` feature by @kazk in https://github.com/kube-rs/kube/pull/1044
### Fixed
* add fieldManager querystring to all operations by @goenning in https://github.com/kube-rs/kube/pull/1031
* Add verify_tls1x_signature for NoCertVerification by @rvql in https://github.com/kube-rs/kube/pull/1034
* Fix compatibility with schemars' preserve_order feature by @teozkr in https://github.com/kube-rs/kube/pull/1050
* Hoist enum values from subschemas by @teozkr in https://github.com/kube-rs/kube/pull/1051

[0.75.0](https://github.com/kube-rs/kube/releases/tag/0.75.0) / 2022-09-21
===================
Expand All @@ -16,7 +99,7 @@ UNRELEASED
### [Upgrade `k8s-openapi` to 0.16 for Kubernetes 1.25](https://github.com/kube-rs/kube/pull/1008)

The update to [k8s-openapi@0.16.0](https://github.com/Arnavion/k8s-openapi/blob/master/CHANGELOG.md#v0160-2022-09-15) makes this the first release with **tentative** Kubernetes 1.25 support.
While the new structs and apis now exist, we **recommend holding off** on using 1.25 until a [deserialization bug in the apiserver](https://github.com/kubernetes/kubernetes/issues/111985) is resolved upstream. See #997 / #1008 for details.
While the new structs and apis now exist, we **recommend holding off** on using 1.25 until a [deserialization bug in the apiserver](https://github.com/kubernetes/kubernetes/issues/111985) is resolved upstream. See [#997](https://github.com/kube-rs/kube/issues/997) / [#1008](https://github.com/kube-rs/kube/issues/1008) for details.

To upgrade, ensure you bump both `kube` and `k8s-openapi`:

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Crates.io](https://img.shields.io/crates/v/kube.svg)](https://crates.io/crates/kube)
[![Rust 1.60](https://img.shields.io/badge/MSRV-1.60-dea584.svg)](https://github.com/rust-lang/rust/releases/tag/1.60.0)
[![Tested against Kubernetes v1_20 and above](https://img.shields.io/badge/MK8SV-v1_20-326ce5.svg)](https://kube.rs/kubernetes-version)
[![Tested against Kubernetes v1_21 and above](https://img.shields.io/badge/MK8SV-v1_21-326ce5.svg)](https://kube.rs/kubernetes-version)
[![Best Practices](https://bestpractices.coreinfrastructure.org/projects/5413/badge)](https://bestpractices.coreinfrastructure.org/projects/5413)
[![Discord chat](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=plastic)](https://discord.gg/tokio)

Expand All @@ -16,8 +16,8 @@ Select a version of `kube` along with the generated [k8s-openapi](https://github

```toml
[dependencies]
kube = { version = "0.75.0", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.16.0", features = ["v1_25"] }
kube = { version = "0.78.0", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.17.0", features = ["v1_26"] }
```

[Features are available](https://github.com/kube-rs/kube/blob/main/kube/Cargo.toml#L18).
Expand Down Expand Up @@ -108,7 +108,7 @@ This now gives a continual stream of events and you do not need to care about th

```rust
while let Some(event) = stream.try_next().await? {
println!("Applied: {}", event.name());
println!("Applied: {}", event.name_any());
}
```

Expand Down Expand Up @@ -152,8 +152,8 @@ Kube has basic support ([with caveats](https://github.com/kube-rs/kube/issues?q=

```toml
[dependencies]
kube = { version = "0.75.0", default-features = false, features = ["client", "rustls-tls"] }
k8s-openapi = { version = "0.16.0", features = ["v1_25"] }
kube = { version = "0.78.0", default-features = false, features = ["client", "rustls-tls"] }
k8s-openapi = { version = "0.17.0", features = ["v1_26"] }
```

This will pull in `rustls` and `hyper-rustls`.
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blacklisted-names = []
disallowed-names = []
12 changes: 8 additions & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ multiple-versions = "deny"
name = "idna"
version = "0.2"

# tokio 1.25 pulls in mio which pulls in older an windows-sys than parking-lot
[[bans.skip]]
# waiting for ahash/getrandom to bump wasi as we have two branches:
# ahash -> getrandom -> wasi old
# tokio -> mio -> wasi new
name = "wasi"
name = "windows-sys"
version = "0.42"

[[bans.skip]]
# waiting for pem to bump base64
# https://github.com/jcreekmore/pem-rs/blob/master/Cargo.toml#L16
name = "base64"
10 changes: 5 additions & 5 deletions e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ name = "boot"
path = "boot.rs"

[features]
latest = ["k8s-openapi/v1_25"]
mk8sv = ["k8s-openapi/v1_20"]
latest = ["k8s-openapi/v1_26"]
mk8sv = ["k8s-openapi/v1_21"]
rustls = ["kube/rustls-tls"]
openssl = ["kube/openssl-tls"]

[dependencies]
anyhow = "1.0.44"
tracing = "0.1.29"
tracing = "0.1.36"
tracing-subscriber = "0.3.3"
futures = "0.3.17"
kube = { path = "../kube", version = "^0.75.0", default-features = false, features = ["client", "runtime", "ws", "admission", "gzip"] }
k8s-openapi = { version = "0.16.0", default-features = false }
kube = { path = "../kube", version = "^0.78.0", default-features = false, features = ["client", "runtime", "ws", "admission", "gzip"] }
k8s-openapi = { version = "0.17.0", default-features = false }
serde_json = "1.0.68"
tokio = { version = "1.14.0", features = ["full"] }
22 changes: 14 additions & 8 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "kube-examples"
version = "0.1.0"
authors = [
"clux <sszynrae@gmail.com>",
"Teo Klestrup Röijezon <teo@nullable.se>",
"Natalie Klestrup Röijezon <nat@nullable.se>",
"kazk <kazk.dev@gmail.com>",
]
publish = false
Expand All @@ -20,7 +20,7 @@ openssl-tls = ["kube/client", "kube/openssl-tls"]
rustls-tls = ["kube/client", "kube/rustls-tls"]
runtime = ["kube/runtime"]
ws = ["kube/ws"]
latest = ["k8s-openapi/v1_25"]
latest = ["k8s-openapi/v1_26"]

[dev-dependencies]
tokio-util = "0.7.0"
Expand All @@ -29,9 +29,9 @@ validator = { version = "0.16.0", features = ["derive"] }
anyhow = "1.0.44"
futures = "0.3.17"
jsonpath_lib = "0.3.0"
kube = { path = "../kube", version = "^0.75.0", default-features = false, features = ["admission"] }
kube-derive = { path = "../kube-derive", version = "^0.75.0", default-features = false } # only needed to opt out of schema
k8s-openapi = { version = "0.16.0", default-features = false }
kube = { path = "../kube", version = "^0.78.0", default-features = false, features = ["admission"] }
kube-derive = { path = "../kube-derive", version = "^0.78.0", default-features = false } # only needed to opt out of schema
k8s-openapi = { version = "0.17.0", default-features = false }
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.68"
serde_yaml = "0.8.21"
Expand All @@ -40,19 +40,20 @@ either = "1.6.1"
schemars = "0.8.6"
static_assertions = "1.1.0"
tar = "0.4.37"
tracing = "0.1.29"
tracing = "0.1.36"
tracing-subscriber = "0.3.3"
warp = { version = "0.3", default-features = false, features = ["tls"] }
http = "0.2.5"
json-patch = "0.2.6"
json-patch = "0.3.0"
tower = { version = "0.4.6", features = ["limit"] }
tower-http = { version = "0.3.2", features = ["trace", "decompression-gzip"] }
hyper = { version = "0.14.13", features = ["client", "http1", "stream", "tcp"] }
thiserror = "1.0.29"
backoff = "0.4.0"
clap = { version = "3.1.9", default-features = false, features = ["std", "cargo", "derive"] }
clap = { version = "4.0", default-features = false, features = ["std", "cargo", "derive"] }
edit = "0.1.3"
tokio-stream = { version = "0.1.9", features = ["net"] }
crossterm = {version = "0.26.0" }

[[example]]
name = "configmapgen_controller"
Expand Down Expand Up @@ -206,3 +207,8 @@ path = "custom_client_trace.rs"
[[example]]
name = "secret_syncer"
path = "secret_syncer.rs"

[[example]]
name = "pod_shell_crossterm"
path = "pod_shell_crossterm.rs"
required-features = ["ws"]
7 changes: 5 additions & 2 deletions examples/configmapgen_controller.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Nightly clippy (0.1.64) considers Drop a side effect, see https://github.com/rust-lang/rust-clippy/issues/9608
#![allow(clippy::unnecessary_lazy_evaluations)]

use anyhow::Result;
use futures::StreamExt;
use k8s_openapi::api::core::v1::ConfigMap;
Expand Down Expand Up @@ -50,14 +53,14 @@ async fn reconcile(generator: Arc<ConfigMapGenerator>, ctx: Arc<Data>) -> Result
.metadata
.namespace
.as_ref()
.ok_or(Error::MissingObjectKey(".metadata.namespace"))?,
.ok_or_else(|| Error::MissingObjectKey(".metadata.namespace"))?,
);
cm_api
.patch(
cm.metadata
.name
.as_ref()
.ok_or(Error::MissingObjectKey(".metadata.name"))?,
.ok_or_else(|| Error::MissingObjectKey(".metadata.name"))?,
&PatchParams::apply("configmapgenerator.kube-rt.nullable.se"),
&Patch::Apply(&cm),
)
Expand Down
4 changes: 2 additions & 2 deletions examples/crd_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
/// Our spec for Foo
///
/// A struct with our chosen Kind will be created for us, using the following kube attrs
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Clone, JsonSchema)]
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema)]
#[kube(
group = "clux.dev",
version = "v1",
Expand Down Expand Up @@ -51,7 +51,7 @@ fn main() {
});
println!("Spec: {:?}", foo.spec);
let crd = serde_json::to_string_pretty(&FooCrd::crd()).unwrap();
println!("Foo CRD: \n{}", crd);
println!("Foo CRD: \n{crd}");

println!("Spec (via HasSpec): {:?}", foo.spec());
println!("Status (via HasStatus): {:?}", foo.status());
Expand Down
2 changes: 0 additions & 2 deletions examples/crd_derive_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ async fn main() -> anyhow::Result<()> {
let newvarv2_2 = v2api.patch("new", &ssapply, &Patch::Apply(&v2m)).await?;
info!("new on v2 correct on reapply to v2: {:?}", newvarv2_2.spec);


// note we can apply old versions without them being truncated to the v2 schema
// in our case this means we cannot fetch them with our v1 schema (breaking change to not have oldprop)
let v1m2 = v1::ManyDerive::new("old", v1::ManyDeriveSpec {
Expand All @@ -101,7 +100,6 @@ async fn main() -> anyhow::Result<()> {
Ok(())
}


async fn apply_crd(client: Client, crd: CustomResourceDefinition) -> anyhow::Result<()> {
let crds: Api<CustomResourceDefinition> = Api::all(client.clone());
info!("Creating crd: {}", serde_yaml::to_string(&crd)?);
Expand Down
4 changes: 2 additions & 2 deletions examples/crd_derive_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
// - https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting
// - https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting-and-nullable

#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Clone, JsonSchema)]
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema)]
#[kube(
group = "clux.dev",
version = "v1",
Expand Down Expand Up @@ -250,7 +250,7 @@ async fn delete_crd(client: Client) -> Result<()> {
return Ok(());
}
}
Err(anyhow!(format!("CRD not deleted after {} seconds", timeout_secs)))
Err(anyhow!(format!("CRD not deleted after {timeout_secs} seconds")))
} else {
Ok(())
}
Expand Down
Loading

0 comments on commit 5d61922

Please sign in to comment.