kube::runtime::watcher

Struct Config

Source
pub struct Config {
    pub label_selector: Option<String>,
    pub field_selector: Option<String>,
    pub timeout: Option<u32>,
    pub list_semantic: ListSemantic,
    pub initial_list_strategy: InitialListStrategy,
    pub page_size: Option<u32>,
    pub bookmarks: bool,
}
Available on crate feature runtime only.
Expand description

Accumulates all options that can be used on the watcher invocation.

Fields§

§label_selector: Option<String>

A selector to restrict the list of returned objects by their labels.

Defaults to everything if None.

§field_selector: Option<String>

A selector to restrict the list of returned objects by their fields.

Defaults to everything if None.

§timeout: Option<u32>

Timeout for the list/watch call.

This limits the duration of the call, regardless of any activity or inactivity. If unset for a watch call, we will use 290s. We limit this to 295s due to inherent watch limitations.

§list_semantic: ListSemantic

Semantics for list calls.

Configures re-list for performance vs. consistency.

NB: This option only has an effect for InitialListStrategy::ListWatch.

§initial_list_strategy: InitialListStrategy

Control how the watcher fetches the initial list of objects.

  • ListWatch: The watcher will fetch the initial list of objects using a list call.
  • StreamingList: The watcher will fetch the initial list of objects using a watch call.

StreamingList is more efficient than ListWatch, but it requires the server to support streaming list bookmarks (opt-in feature gate in Kubernetes 1.27).

See upstream documentation on streaming lists, and the KEP.

§page_size: Option<u32>

Maximum number of objects retrieved per list operation resyncs.

This can reduce the memory consumption during resyncs, at the cost of requiring more API roundtrips to complete.

Defaults to 500. Note that None represents unbounded.

NB: This option only has an effect for InitialListStrategy::ListWatch.

§bookmarks: bool

Enables watch events with type “BOOKMARK”.

Requests watch bookmarks from the apiserver when enabled for improved watch precision and reduced list calls. This is default enabled and should generally not be turned off.

Implementations§

Source§

impl Config

Builder interface to Config

Usage:

use kube::runtime::watcher::Config;
let wc = Config::default()
    .timeout(60)
    .labels("kubernetes.io/lifecycle=spot");
Source

pub fn timeout(self, timeout_secs: u32) -> Config

Configure the timeout for list/watch calls

This limits the duration of the call, regardless of any activity or inactivity. Defaults to 290s

Source

pub fn fields(self, field_selector: &str) -> Config

Configure the selector to restrict the list of returned objects by their fields.

Defaults to everything. Supports =, ==, !=, and can be comma separated: key1=value1,key2=value2. The server only supports a limited number of field queries per type.

Source

pub fn labels(self, label_selector: &str) -> Config

Configure the selector to restrict the list of returned objects by their labels.

Defaults to everything. Supports =, ==, !=, and can be comma separated: key1=value1,key2=value2.

Source

pub fn labels_from(self, selector: &Selector) -> Config

Configure typed label selectors

Configure typed selectors from Selector and Expression lists.

use kube_runtime::watcher::Config;
use kube_client::core::{Expression, Selector, ParseExpressionError};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector;
let selector: Selector = Expression::In("env".into(), ["development".into(), "sandbox".into()].into()).into();
let cfg = Config::default().labels_from(&selector);
let cfg = Config::default().labels_from(&Expression::Exists("foo".into()).into());
let selector: Selector = LabelSelector::default().try_into()?;
let cfg = Config::default().labels_from(&selector);
Source

pub fn list_semantic(self, semantic: ListSemantic) -> Config

Sets list semantic to configure re-list performance and consistency

NB: This option only has an effect for InitialListStrategy::ListWatch.

Source

pub fn any_semantic(self) -> Config

Sets list semantic to Any to improve list performance

NB: This option only has an effect for InitialListStrategy::ListWatch.

Source

pub fn disable_bookmarks(self) -> Config

Disables watch bookmarks to simplify watch handling

This is not recommended to use with production watchers as it can cause desyncs. See #219 for details.

Source

pub fn page_size(self, page_size: u32) -> Config

Limits the number of objects retrieved in each list operation during resync.

This can reduce the memory consumption during resyncs, at the cost of requiring more API roundtrips to complete.

NB: This option only has an effect for InitialListStrategy::ListWatch.

Source

pub fn streaming_lists(self) -> Config

Kubernetes 1.27 Streaming Lists Sets list semantic to Stream to make use of watch bookmarks

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T