Skip to content

[DO NOT LAND] Allow us to disable namespace listwatching #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: upstream_master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions src/sources/kubernetes_logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ pub struct Config {
))]
extra_namespace_label_selector: String,

/// Specifies whether or not to enrich with namespace fields.
///
/// This can be useful to make Vector not pull in namespaces to reduce load on
/// kube-apiserver and daemonset memory usage in clusters with lots of namespaces.
///
add_namespace_fields: bool,

/// The name of the Kubernetes [Node][node] that is running.
///
/// Configured to use an environment variable by default, to be evaluated to a value provided by
Expand Down Expand Up @@ -280,6 +287,7 @@ impl Default for Config {
Self {
extra_label_selector: "".to_string(),
extra_namespace_label_selector: "".to_string(),
add_namespace_fields: true,
self_node_name: default_self_node_name_env_template(),
extra_field_selector: "".to_string(),
auto_partial_merge: true,
Expand Down Expand Up @@ -544,6 +552,7 @@ struct Source {
field_selector: String,
label_selector: String,
namespace_label_selector: String,
add_namespace_fields: bool,
node_selector: String,
self_node_name: String,
include_paths: Vec<glob::Pattern>,
Expand Down Expand Up @@ -632,6 +641,7 @@ impl Source {
field_selector,
label_selector,
namespace_label_selector,
add_namespace_fields: config.add_namespace_fields,
node_selector,
self_node_name,
include_paths,
Expand Down Expand Up @@ -667,6 +677,7 @@ impl Source {
field_selector,
label_selector,
namespace_label_selector,
add_namespace_fields,
node_selector,
self_node_name,
include_paths,
Expand Down Expand Up @@ -720,27 +731,29 @@ impl Source {

// -----------------------------------------------------------------

let namespaces = Api::<Namespace>::all(client.clone());
let ns_watcher = watcher(
namespaces,
watcher::Config {
label_selector: Some(namespace_label_selector),
list_semantic: list_semantic.clone(),
page_size: get_page_size(use_apiserver_cache),
..Default::default()
},
)
.backoff(watcher::DefaultBackoff::default());
let ns_store_w = reflector::store::Writer::default();
let ns_state = ns_store_w.as_reader();
let ns_cacher = MetaCache::new();

reflectors.push(tokio::spawn(custom_reflector(
ns_store_w,
ns_cacher,
ns_watcher,
delay_deletion,
)));
if add_namespace_fields {
let namespaces = Api::<Namespace>::all(client.clone());
let ns_watcher = watcher(
namespaces,
watcher::Config {
label_selector: Some(namespace_label_selector),
list_semantic: list_semantic.clone(),
page_size: get_page_size(use_apiserver_cache),
..Default::default()
},
)
.backoff(watcher::DefaultBackoff::default());
let ns_cacher = MetaCache::new();

reflectors.push(tokio::spawn(custom_reflector(
ns_store_w,
ns_cacher,
ns_watcher,
delay_deletion,
)));
}

// -----------------------------------------------------------------

Expand Down
Loading