Skip to content

Commit c4fcfea

Browse files
committed
client: document TLS features
This commit adds some documentation describing how TLS implementations are selected. I figured this would be nice to add. Signed-off-by: Eliza Weisman <[email protected]>
1 parent 589f644 commit c4fcfea

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

kube-client/src/client/builder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ impl<Svc> ClientBuilder<Svc> {
6464
impl TryFrom<Config> for ClientBuilder<BoxService<Request<hyper::Body>, Response<Box<DynBody>>, BoxError>> {
6565
type Error = Error;
6666

67-
/// Builds a default [`ClientBuilder`] stack from a given configuration
67+
/// Builds a default [`ClientBuilder`] stack from a given configuration.
68+
///
69+
/// The TLS implementation used by the constructed client depends on which
70+
/// crate feature flags are enabled. See [the documentation on configuring
71+
/// TLS](crate::client#configuring-tls) for details.
6872
fn try_from(config: Config) -> Result<Self> {
6973
use std::time::Duration;
7074

kube-client/src/client/mod.rs

+42
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,44 @@
77
//!
88
//! The [`Client`] can also be used with [`Discovery`](crate::Discovery) to dynamically
99
//! retrieve the resources served by the kubernetes API.
10+
//!
11+
//! ## Configuring TLS
12+
//!
13+
//! The Kubernetes client provided by this crate can be configured to use TLS
14+
//! when connecting to the Kubernetes API. A variety of TLS implementations may
15+
//! be used as the backend for `kube-client`'s TLS support, with the choice of
16+
//! TLS backend controlled by crate feature flags. The following TLS backends
17+
//! are available:
18+
//!
19+
//! | TLS backend | Crate feature flag | Description |
20+
//! |:------------|--------------------|-------------|
21+
//! | `<none>` | `<none>` | When no TLS feature flag is enabled, communication with the Kubernetes API is plaintext. |
22+
//! | [Rustls] | `rustls-tls` | [Rustls] is a pure-Rust TLS implementation. |
23+
//! | [OpenSSL] | `openssl-tls` | [OpenSSL] is a popular TLS implementation written in C. This feature uses the [`openssl` crate]'s Rust bindings for OpenSSL. |
24+
//! | [BoringSSL] | `boring-tls` | [BoringSSL] is a fork of OpenSSL maintained by Google. This feature uses the [`boring` crate]'s Rust bindings for BoringSSL. |
25+
//!
26+
//! Since crate feature flags are additive, more than one TLS feature may be
27+
//! enabled at the same time. However, only one TLS backend may actually be
28+
//! selected. Therefore, conflicts are resolved by selecting one TLS backend,
29+
//! with the following order of priority:
30+
//!
31+
//! 1. **rustls-tls**: If the `rustls-tls` feature is enabled, [Rustls] is
32+
//! always used as the TLS implementation, regardless of what other feature
33+
//! flags are enabled.
34+
//! 2. **openssl-tls**: If the `rustls-tls` feature is not enabled, but the
35+
//! `openssl-tls` feature flag is enabled, then [OpenSSL] is used instead of
36+
//! Rustls.
37+
//! 3. **boring-tls**: If neither the `rustls-tls` nor `openssl-tls` features
38+
//! are enabled, [BoringSSL] is used as the TLS backend.
39+
//! 4. **none**: If none of the `rustls-tls`, `openssl-tls`, and `boring-tls`
40+
//! features are enabled, all communication with the Kubernetes API is
41+
//! plaintext.
42+
//!
43+
//! [Rustls]: https://crates.io/crates/rustls
44+
//! [OpenSSL]: https://www.openssl.org/
45+
//! [`openssl` crate]: https://crates.io/crates/openssl
46+
//! [BoringSSL]: https://github.com/google/boringssl
47+
//! [`boring` crate]: https://crates.io/crates/boring
1048
use either::{Either, Left, Right};
1149
use futures::{self, AsyncBufRead, StreamExt, TryStream, TryStreamExt};
1250
use http::{self, Request, Response, StatusCode};
@@ -131,6 +169,10 @@ impl Client {
131169
///
132170
/// If you already have a [`Config`] then use [`Client::try_from`](Self::try_from)
133171
/// instead.
172+
///
173+
/// The TLS implementation used by the returned client depends on which
174+
/// crate feature flags are enabled. See [the documentation on configuring
175+
/// TLS](crate::client#configuring-tls) for details.
134176
pub async fn try_default() -> Result<Self> {
135177
Self::try_from(Config::infer().await.map_err(Error::InferConfig)?)
136178
}

0 commit comments

Comments
 (0)