SpreadRule

Struct SpreadRule 

Source
pub struct SpreadRule {
    pub topology_key: String,
    pub max_skew: Option<i32>,
    pub when_unsatisfiable: Option<WhenUnsatisfiable>,
    pub scope: Option<SpreadScope>,
    pub min_domains: Option<i32>,
    pub node_affinity_policy: Option<NodeInclusionPolicy>,
    pub node_taints_policy: Option<NodeInclusionPolicy>,
}
Expand description

A single topology spread rule.

Each rule becomes exactly one entry in the Pod’s spec.topologySpreadConstraints, with the labelSelector generated from SpreadScope rather than written by hand — users have no way to know the operator’s internal Pod labels, and getting the selector wrong silently produces a constraint that does nothing.

§Example

spread:
  # Spread primaries across zones first — hard requirement.
  - topologyKey: topology.kubernetes.io/zone
    maxSkew: 1
    whenUnsatisfiable: DoNotSchedule
    scope: Role
  # Then, within a zone, prefer separate nodes.
  - topologyKey: kubernetes.io/hostname
    maxSkew: 1
    whenUnsatisfiable: ScheduleAnyway
    scope: Role

Fields§

§topology_key: String

Node label key that defines the failure domain.

Nodes sharing a value for this label are in the same domain. Any node label works, which is the point: clusters that do not use the well-known zone label can spread across whatever they do use.

Examples:

  • topology.kubernetes.io/zone - availability zone (the usual choice)
  • topology.kubernetes.io/region - region, for multi-region clusters
  • kubernetes.io/hostname - individual nodes
  • failure-domain.acme.io/rack - a custom, on-prem failure domain
  • karpenter.sh/capacity-type - spot vs. on-demand capacity

Must be a valid Kubernetes qualified name, matching what the API server accepts for a node label key: an optional lowercase RFC 1123 subdomain prefix of at most 253 characters, a /, and a name segment of at most 63 characters. The maximum overall length is therefore 317.

The 253-character prefix cap is enforced by an x-kubernetes-validations rule on the parent rule rather than by the pattern below: CRD patterns are RE2, which has no lookahead, so a length bound on a variable-length prefix cannot be expressed in the regex itself.

§max_skew: Option<i32>

Maximum permitted difference in Pod count between any two domains.

Default: 1 (the tightest useful value — every domain is filled before any domain doubles up).

§when_unsatisfiable: Option<WhenUnsatisfiable>

What the scheduler does when the rule cannot be satisfied.

Default: ScheduleAnyway (soft). The operator defaults to soft deliberately: a hard constraint turns a single-zone cluster, or a zone outage, into Pending DNS Pods — trading an availability problem for a total outage. Set DoNotSchedule only when you know the cluster has at least as many domains as you have replicas.

§scope: Option<SpreadScope>

Which Pods this rule balances. See SpreadScope.

Default: Role for a cluster-managed instance (spread all primaries of the cluster across zones), Instance for a standalone Bind9Instance (spread that instance’s own replicas).

The default is almost always what you want. Override it only when you deliberately want primaries and secondaries balanced together (Cluster), or want to opt a multi-replica standalone instance out of cluster-wide balancing (Instance).

§min_domains: Option<i32>

Minimum number of domains that must be eligible.

Only meaningful together with whenUnsatisfiable: DoNotSchedule. When fewer than minDomains domains exist, the constraint is treated as unsatisfiable. Use it to fail loudly rather than silently running all your nameservers in one zone.

§node_affinity_policy: Option<NodeInclusionPolicy>

Whether the Pod’s node affinity / node selector is honoured when counting domains.

Default: Honor (the Kubernetes default). Ignore counts every node, including ones this Pod could never be scheduled onto.

§node_taints_policy: Option<NodeInclusionPolicy>

Whether node taints are honoured when counting domains.

Default: Ignore (the Kubernetes default).

Trait Implementations§

Source§

impl Clone for SpreadRule

Source§

fn clone(&self) -> SpreadRule

Returns a duplicate 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 SpreadRule

Source§

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

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

impl<'de> Deserialize<'de> for SpreadRule

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for SpreadRule

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for SpreadRule

Source§

fn eq(&self, other: &SpreadRule) -> 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 Serialize for SpreadRule

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for SpreadRule

Source§

impl StructuralPartialEq for SpreadRule

Auto Trait Implementations§

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, dest: *mut u8)

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

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

Source§

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

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,