Skip to content

Commit

Permalink
feat: add topologySpreadConstraints to kops cluster crd
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Luiz Pereira Nunes authored and Thiago Luiz Pereira Nunes committed Dec 10, 2024
1 parent b6bcf4b commit 3cd9815
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
110 changes: 110 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3748,6 +3748,116 @@ spec:
items:
type: string
type: array
topologySpreadConstraints:
description: |-
You can use topology spread constraints to control how Pods are spread across your cluster
among failure-domains such as regions, zones, nodes, and other user-defined topology domains.
items:
description: |-
You can define one or multiple topologySpreadConstraints entries to instruct the kube-scheduler
how to place each incoming Pod in relation to the existing Pods across your cluster.
properties:
maxSkew:
description: |-
maxSkew describes the degree to which Pods may be unevenly distributed. You must specify this field
and the number must be greater than zero.
type: integer
minDomains:
description: |-
minDomains indicates a minimum number of eligible domains. This field is optional. A domain is a particular
instance of a topology. An eligible domain is a domain whose nodes match the node selector.
type: integer
topologyKey:
description: |-
topologyKey is the key of node labels. Nodes that have a label with this key and identical values are considered
to be in the same topology. We call each instance of a topology (in other words, a <key, value> pair) a domain.
type: string
whenUnsatisfiable:
description: |-
whenUnsatisfiable indicates how to deal with a Pod if it doesn't satisfy the spread constraint:
DoNotSchedule (default) tells the scheduler not to schedule it.
ScheduleAnyway tells the scheduler to still schedule it while prioritizing nodes that minimize the skew.
type: string
labelSelector:
description: |-
A label query over a set of resources, in this case pods.
If it's null, this PodAffinityTerm matches with no Pods.
properties:
matchExpressions:
description: matchExpressions is a list
of label selector requirements. The requirements
are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key
that the selector applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
description: |-
MatchLabelKeys is a set of pod label keys to select which pods will
be taken into consideration. The keys are used to lookup values from the
incoming pod labels, those key-value labels are merged with `labelSelector` as `key in (value)`
to select the group of existing pods which pods will be taken into consideration
for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming
pod labels will be ignored. The default value is empty.
The same key is forbidden to exist in both matchLabelKeys and labelSelector.
Also, matchLabelKeys cannot be set when labelSelector isn't set.
This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
items:
type: string
type: array
x-kubernetes-list-type: atomic
nodeAffinityPolicy:
description: |-
nodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector when calculating pod topology spread skew. Options are:
Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations.
Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations.
If this value is null, the behavior is equivalent to the Honor policy.
type: string
nodeTaintsPolicy:
description: |-
nodeTaintsPolicy indicates how we will treat node taints when calculating pod topology spread skew. Options are:
Honor: nodes without taints, along with tainted nodes for which the incoming pod has a toleration, are included.
Ignore: node taints are ignored. All nodes are included.
If this value is null, the behavior is equivalent to the Ignore policy.
type: string
type: object
type: array
type: object
kubeProxy:
description: KubeProxyConfig defines the configuration for a proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ type KubeDNSConfig struct {
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// NodeLocalDNS specifies the configuration for the node-local-dns addon
NodeLocalDNS *NodeLocalDNSConfig `json:"nodeLocalDNS,omitempty"`
// TopologySpreadConstraints describes how a group of pods ought to spread across topology domains
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

// NodeLocalDNSConfig are options of the node-local-dns
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ type KubeDNSConfig struct {
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// NodeLocalDNS specifies the configuration for the node-local-dns addon
NodeLocalDNS *NodeLocalDNSConfig `json:"nodeLocalDNS,omitempty"`
// TopologySpreadConstraints describes how a group of pods ought to spread across topology domains
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

// NodeLocalDNSConfig are options of the node-local-dns
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha3/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ type KubeDNSConfig struct {
MemoryLimit *resource.Quantity `json:"memoryLimit,omitempty"`
// NodeLocalDNS specifies the configuration for the node-local-dns addon
NodeLocalDNS *NodeLocalDNSConfig `json:"nodeLocalDNS,omitempty"`
// TopologySpreadConstraints describes how a group of pods ought to spread across topology domains
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

// NodeLocalDNSConfig are options of the node-local-dns
Expand Down

0 comments on commit 3cd9815

Please sign in to comment.