Skip to content
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

Add topologySpreadConstraints #155

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions api/v1alpha1/dragonfly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ type DragonflySpec struct {
// +kubebuilder:validation:Optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// (Optional) Dragonfly pod topologySpreadConstraints
// +optional
// +kubebuilder:validation:Optional
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`

// (Optional) Dragonfly Authentication mechanism
// +optional
// +kubebuilder:validation:Optional
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions config/crd/bases/dragonflydb.io_dragonflies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,103 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
description: (Optional) Dragonfly pod topologySpreadConstraints
items:
description: The pod this TopologySpreadConstraints is attached
properties:
maxSkew:
description: the degree to which Pods may be unevenly distributed.
You must specify this field and the number must be greater than zero.
Its semantics differ according to the value of whenUnsatisfiable
format: int32
type: integer
minDomains:
description: (Optional) 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
format: int32
type: integer
topologyKey:
description: 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.
The scheduler will try to put a balanced number of pods into each domain.
Also, we define an eligible domain as a domain whose nodes meet the
requirements of nodeAffinityPolicy and nodeTaintsPolicy.
type: string
whenUnsatisfiable:
description: 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.
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
required:
- key
- operator
type: object
type: array
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: field is a beta-level field and enabled by default in 1.27.
You can disable it by disabling the MatchLabelKeysInPodTopologySpread
items:
type: string
type: array
nodeAffinityPolicy:
description: indicates how we will treat Pod's nodeAffinity/nodeSelector
when calculating pod topology spread skew. Options are Honor or Ignore
type: string
nodeTaintsPolicy:
description: indicates how we will treat node taints when calculating pod topology spread skew. Honor or Ignore
type: string
type: object
type: array
type: object
status:
description: DragonflyStatus defines the observed state of Dragonfly
Expand Down
4 changes: 4 additions & 0 deletions internal/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ func GetDragonflyResources(ctx context.Context, df *resourcesv1.Dragonfly) ([]cl
statefulset.Spec.Template.Spec.Tolerations = df.Spec.Tolerations
}

if df.Spec.TopologySpreadConstraints != nil {
statefulset.Spec.Template.Spec.TopologySpreadConstraints = df.Spec.TopologySpreadConstraints
}

if df.Spec.ServiceAccountName != "" {
statefulset.Spec.Template.Spec.ServiceAccountName = df.Spec.ServiceAccountName
}
Expand Down
97 changes: 97 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,103 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
description: (Optional) Dragonfly pod topologySpreadConstraints
items:
description: The pod this TopologySpreadConstraints is attached
properties:
maxSkew:
description: the degree to which Pods may be unevenly distributed.
You must specify this field and the number must be greater than zero.
Its semantics differ according to the value of whenUnsatisfiable
format: int32
type: integer
minDomains:
description: (Optional) 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
format: int32
type: integer
topologyKey:
description: 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.
The scheduler will try to put a balanced number of pods into each domain.
Also, we define an eligible domain as a domain whose nodes meet the
requirements of nodeAffinityPolicy and nodeTaintsPolicy.
type: string
whenUnsatisfiable:
description: 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.
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
required:
- key
- operator
type: object
type: array
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: field is a beta-level field and enabled by default in 1.27.
You can disable it by disabling the MatchLabelKeysInPodTopologySpread
items:
type: string
type: array
nodeAffinityPolicy:
description: indicates how we will treat Pod's nodeAffinity/nodeSelector
when calculating pod topology spread skew. Options are Honor or Ignore
type: string
nodeTaintsPolicy:
description: indicates how we will treat node taints when calculating pod topology spread skew. Honor or Ignore
type: string
type: object
type: array
type: object
status:
description: DragonflyStatus defines the observed state of Dragonfly
Expand Down
97 changes: 97 additions & 0 deletions manifests/dragonfly-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,103 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
description: (Optional) Dragonfly pod topologySpreadConstraints
items:
description: The pod this TopologySpreadConstraints is attached
properties:
maxSkew:
description: the degree to which Pods may be unevenly distributed.
You must specify this field and the number must be greater than zero.
Its semantics differ according to the value of whenUnsatisfiable
format: int32
type: integer
minDomains:
description: (Optional) 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
format: int32
type: integer
topologyKey:
description: 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.
The scheduler will try to put a balanced number of pods into each domain.
Also, we define an eligible domain as a domain whose nodes meet the
requirements of nodeAffinityPolicy and nodeTaintsPolicy.
type: string
whenUnsatisfiable:
description: 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.
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
required:
- key
- operator
type: object
type: array
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: field is a beta-level field and enabled by default in 1.27.
You can disable it by disabling the MatchLabelKeysInPodTopologySpread
items:
type: string
type: array
nodeAffinityPolicy:
description: indicates how we will treat Pod's nodeAffinity/nodeSelector
when calculating pod topology spread skew. Options are Honor or Ignore
type: string
nodeTaintsPolicy:
description: indicates how we will treat node taints when calculating pod topology spread skew. Honor or Ignore
type: string
type: object
type: array
type: object
status:
description: DragonflyStatus defines the observed state of Dragonfly
Expand Down
Loading