Skip to content

Commit

Permalink
Fix minor new lints and better info on pod reflector memory usage (#1440
Browse files Browse the repository at this point in the history
)

* Fix minor new lints and better info on pod reflector memory usage

caused a question and the figure is old and not necessarily super helpful.
making it deliberately more vague and redirecting to actual graphs.

Signed-off-by: clux <[email protected]>

* fix link lint and an old misleading comment

Signed-off-by: clux <[email protected]>

---------

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux authored Mar 25, 2024
1 parent 2ff3a2d commit 89b9e5f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kube-client/src/client/config_ext.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use http::{header::HeaderName, HeaderValue};
use hyper::rt::{Read, Write};
#[cfg(feature = "openssl-tls")] use hyper::rt::{Read, Write};
use hyper_util::client::legacy::connect::HttpConnector;
use secrecy::ExposeSecret;
use tower::{filter::AsyncFilterLayer, util::Either};
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/client/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod tests {
}

fn test_token(token: String) -> RefreshableToken {
let expiry = Utc::now() + Duration::seconds(60 * 60);
let expiry = Utc::now() + Duration::try_seconds(60 * 60).unwrap();
let secret_token = SecretString::from(token);
let info = AuthInfo {
token: Some(secret_token.clone()),
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use either::{Either, Left, Right};
use futures::{self, AsyncBufRead, StreamExt, TryStream, TryStreamExt};
use http::{self, Request, Response};
use http_body_util::BodyExt;
use hyper_util::rt::TokioIo;
#[cfg(feature = "ws")] use hyper_util::rt::TokioIo;
use k8s_openapi::apimachinery::pkg::apis::meta::v1 as k8s_meta_v1;
pub use kube_core::response::Status;
use serde::de::DeserializeOwned;
Expand Down
5 changes: 2 additions & 3 deletions kube-client/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ impl Config {
/// `/var/run/secrets/kubernetes.io/serviceaccount/`.
///
/// This behavior does not match that of the official Kubernetes clients,
/// but this approach is compatible with the `rustls-tls` feature
/// without setting `tls_server_name`.
/// See <https://github.com/kube-rs/kube/issues/1003>.
/// but can be used as a consistent entrypoint in many clusters.
/// See <https://github.com/kube-rs/kube/issues/1003> for more info.
pub fn incluster_dns() -> Result<Self, InClusterError> {
Self::incluster_with_uri(incluster_config::kube_dns())
}
Expand Down
7 changes: 5 additions & 2 deletions kube-runtime/src/reflector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ pub use store::{store, Store};
/// ## Memory Usage
///
/// A reflector often constitutes one of the biggest components of a controller's memory use.
/// Given ~two thousand pods in a cluster, a reflector around that quickly consumes 1GB of memory.
/// Given a ~2000 pods cluster, a reflector saving everything (including injected sidecars, managed fields)
/// can quickly consume a couple of hundred megabytes or more, depending on how much of this you are storing.
///
/// While, sometimes acceptible, there are techniques you can leverage to reduce the memory usage
/// While generally acceptable, there are techniques you can leverage to reduce the memory usage
/// depending on your use case.
///
/// 1. Reflect a [`PartialObjectMeta<K>`](kube_client::core::PartialObjectMeta) stream rather than a stream of `K`
Expand Down Expand Up @@ -88,6 +89,8 @@ pub use store::{store, Store};
/// The `stream` can then be passed to `reflector` causing smaller objects to be written to its store.
/// Note that you **cannot drop everything**; you minimally need the spec properties your app relies on.
/// Additionally, only `labels`, `annotations` and `managed_fields` are safe to drop from `ObjectMeta`.
///
/// For more information check out: <https://kube.rs/controllers/optimization/> for graphs and techniques.
pub fn reflector<K, W>(mut writer: store::Writer<K>, stream: W) -> impl Stream<Item = W::Item>
where
K: Lookup + Clone,
Expand Down

0 comments on commit 89b9e5f

Please sign in to comment.