Skip to content
Docs Try Aspire

TopologySpreadConstraintV1

Class sealed net10.0
📦 Aspire.Hosting.Kubernetes v13.1.2-preview.1.26125.13
Represents the topology spread constraints for distributing pods across a Kubernetes cluster. These constraints define policies for balancing pods across different node topologies such as zones or regions. The constraints aim to ensure high availability and resilience by spreading pods evenly based on the specified rules.
namespace Aspire.Hosting.Kubernetes.Resources;
public sealed class TopologySpreadConstraintV1
{
// ...
}
The following properties define the rules for the constraint: - `WhenUnsatisfiable`: Defines the behavior when the constraint is unsatisfiable. For example, it can be set to "DoNotSchedule" to prevent scheduling pods if the rule cannot be satisfied. - `LabelSelector`: Specifies the selector to identify the set of target pods for applying the constraint. - `MatchLabelKeys`: A list of label key names that must exist on nodes to be considered during the spread calculation. - `MinDomains`: Specifies the minimum number of topology domains that must satisfy the spread constraint. - `MaxSkew`: Defines the maximum skew, which is the difference in the number of pods across the topology domains. An uneven skew would trigger balancing of pods. - `NodeAffinityPolicy`: Determines the policy for using node affinity to influence pod placement. - `NodeTaintsPolicy`: Specifies the policy regarding node taints when scheduling the pods. - `TopologyKey`: Represents the key of a label that defines the topology domains for spreading, such as "zone" or "rack".
View all constructors
LabelSelectorget; set
Gets or sets the label selector used for dynamically filtering Kubernetes resources based on their labels. This property enables the selection of specific objects by defining criteria that must match the labels within the resource set.
MatchLabelKeysget
List<string>
Defines a list of specific label keys that are required to be matched for topology spreading constraints.
MaxSkewget; set
int?
Represents the maximum allowed skew for a topology spread constraint in Kubernetes. Skew is defined as the difference in the number of matching pods between the target and the other domains defined by the topologyKey.
MinDomainsget; set
int?
Specifies the minimum number of topology domains that must have at least one replica present for resource scheduling. This is used to ensure that replicas are distributed across a certain number of domains to achieve a balanced topology spread for better availability and fault tolerance.
NodeAffinityPolicyget; set
string?
Defines the policy for node affinity within a Kubernetes topology spread constraint. Determines how nodes are selected to satisfy the specified affinity rules.
NodeTaintsPolicyget; set
string?
Gets or sets the policy for handling node taints within a topology spread constraint.
TopologyKeyget; set
string?
Represents the key used to indicate the topology domain of a Kubernetes resource. The TopologyKey defines the scope for spreading or balancing resources across nodes based on the specified topology rule. It is typically matched to a node label, such as failure-domain.beta.kubernetes.io/zone or kubernetes.io/hostname, to align resources with the desired domain or affinity policy.
WhenUnsatisfiableget; set
string?
Specifies the behavior when the constraints defined for topology spreading cannot be satisfied. This is used to handle scenarios where the node placement does not meet the desired topology spread constraints.
View all properties