Skip to content

Commit c40fa1c

Browse files
committed
feat: add topologySpreadConstraints for emqx CRD
Signed-off-by: Rory Z <[email protected]>
1 parent 20b8df4 commit c40fa1c

File tree

9 files changed

+231
-8
lines changed

9 files changed

+231
-8
lines changed

apis/apps/v2beta1/emqx_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ type EMQXReplicantTemplateSpec struct {
196196
// If specified, the pod's tolerations.
197197
// The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator .
198198
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
199+
//// TopologySpreadConstraint specifies how to spread matching pods among the given topology.
200+
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
199201
// Replicas is the desired number of replicas of the given Template.
200202
// These are replicas in the sense that they are instantiations of the
201203
// same Template, but individual replicas also have a consistent identity.

apis/apps/v2beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apps.emqx.io_emqxes.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10100,6 +10100,58 @@ spec:
1010010100
type: string
1010110101
type: object
1010210102
type: array
10103+
topologySpreadConstraints:
10104+
items:
10105+
properties:
10106+
labelSelector:
10107+
properties:
10108+
matchExpressions:
10109+
items:
10110+
properties:
10111+
key:
10112+
type: string
10113+
operator:
10114+
type: string
10115+
values:
10116+
items:
10117+
type: string
10118+
type: array
10119+
required:
10120+
- key
10121+
- operator
10122+
type: object
10123+
type: array
10124+
matchLabels:
10125+
additionalProperties:
10126+
type: string
10127+
type: object
10128+
type: object
10129+
x-kubernetes-map-type: atomic
10130+
matchLabelKeys:
10131+
items:
10132+
type: string
10133+
type: array
10134+
x-kubernetes-list-type: atomic
10135+
maxSkew:
10136+
format: int32
10137+
type: integer
10138+
minDomains:
10139+
format: int32
10140+
type: integer
10141+
nodeAffinityPolicy:
10142+
type: string
10143+
nodeTaintsPolicy:
10144+
type: string
10145+
topologyKey:
10146+
type: string
10147+
whenUnsatisfiable:
10148+
type: string
10149+
required:
10150+
- maxSkew
10151+
- topologyKey
10152+
- whenUnsatisfiable
10153+
type: object
10154+
type: array
1010310155
volumeClaimTemplates:
1010410156
properties:
1010510157
accessModes:
@@ -13593,6 +13645,58 @@ spec:
1359313645
type: string
1359413646
type: object
1359513647
type: array
13648+
topologySpreadConstraints:
13649+
items:
13650+
properties:
13651+
labelSelector:
13652+
properties:
13653+
matchExpressions:
13654+
items:
13655+
properties:
13656+
key:
13657+
type: string
13658+
operator:
13659+
type: string
13660+
values:
13661+
items:
13662+
type: string
13663+
type: array
13664+
required:
13665+
- key
13666+
- operator
13667+
type: object
13668+
type: array
13669+
matchLabels:
13670+
additionalProperties:
13671+
type: string
13672+
type: object
13673+
type: object
13674+
x-kubernetes-map-type: atomic
13675+
matchLabelKeys:
13676+
items:
13677+
type: string
13678+
type: array
13679+
x-kubernetes-list-type: atomic
13680+
maxSkew:
13681+
format: int32
13682+
type: integer
13683+
minDomains:
13684+
format: int32
13685+
type: integer
13686+
nodeAffinityPolicy:
13687+
type: string
13688+
nodeTaintsPolicy:
13689+
type: string
13690+
topologyKey:
13691+
type: string
13692+
whenUnsatisfiable:
13693+
type: string
13694+
required:
13695+
- maxSkew
13696+
- topologyKey
13697+
- whenUnsatisfiable
13698+
type: object
13699+
type: array
1359613700
type: object
1359713701
type: object
1359813702
revisionHistoryLimit:

controllers/apps/v2beta1/add_emqx_core.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ func generateStatefulSet(instance *appsv2beta1.EMQX) *appsv1.StatefulSet {
185185
// TODO: just for compatible with old version, will remove in future
186186
instance.Spec.CoreTemplate.Spec.ToleRations...,
187187
),
188-
NodeName: instance.Spec.CoreTemplate.Spec.NodeName,
189-
NodeSelector: instance.Spec.CoreTemplate.Spec.NodeSelector,
190-
InitContainers: instance.Spec.CoreTemplate.Spec.InitContainers,
188+
TopologySpreadConstraints: instance.Spec.CoreTemplate.Spec.TopologySpreadConstraints,
189+
NodeName: instance.Spec.CoreTemplate.Spec.NodeName,
190+
NodeSelector: instance.Spec.CoreTemplate.Spec.NodeSelector,
191+
InitContainers: instance.Spec.CoreTemplate.Spec.InitContainers,
191192
Containers: append([]corev1.Container{
192193
{
193194
Name: appsv2beta1.DefaultContainerName,

controllers/apps/v2beta1/add_emqx_repl.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,10 @@ func generateReplicaSet(instance *appsv2beta1.EMQX) *appsv1.ReplicaSet {
191191
// TODO: just for compatible with old version, will remove in future
192192
instance.Spec.ReplicantTemplate.Spec.ToleRations...,
193193
),
194-
NodeName: instance.Spec.ReplicantTemplate.Spec.NodeName,
195-
NodeSelector: instance.Spec.ReplicantTemplate.Spec.NodeSelector,
196-
InitContainers: instance.Spec.ReplicantTemplate.Spec.InitContainers,
194+
TopologySpreadConstraints: instance.Spec.CoreTemplate.Spec.TopologySpreadConstraints,
195+
NodeName: instance.Spec.ReplicantTemplate.Spec.NodeName,
196+
NodeSelector: instance.Spec.ReplicantTemplate.Spec.NodeSelector,
197+
InitContainers: instance.Spec.ReplicantTemplate.Spec.InitContainers,
197198
Containers: append([]corev1.Container{
198199
{
199200
Name: appsv2beta1.DefaultContainerName,

deploy/charts/emqx-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 2.2.20
18+
version: 2.2.21
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
23-
appVersion: 2.2.20
23+
appVersion: 2.2.21
2424

2525
sources:
2626
- https://github.com/emqx/emqx-operator/tree/main/deploy/charts/emqx-operator

deploy/charts/emqx-operator/templates/crd.emqxes.apps.emqx.io.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10112,6 +10112,58 @@ spec:
1011210112
type: string
1011310113
type: object
1011410114
type: array
10115+
topologySpreadConstraints:
10116+
items:
10117+
properties:
10118+
labelSelector:
10119+
properties:
10120+
matchExpressions:
10121+
items:
10122+
properties:
10123+
key:
10124+
type: string
10125+
operator:
10126+
type: string
10127+
values:
10128+
items:
10129+
type: string
10130+
type: array
10131+
required:
10132+
- key
10133+
- operator
10134+
type: object
10135+
type: array
10136+
matchLabels:
10137+
additionalProperties:
10138+
type: string
10139+
type: object
10140+
type: object
10141+
x-kubernetes-map-type: atomic
10142+
matchLabelKeys:
10143+
items:
10144+
type: string
10145+
type: array
10146+
x-kubernetes-list-type: atomic
10147+
maxSkew:
10148+
format: int32
10149+
type: integer
10150+
minDomains:
10151+
format: int32
10152+
type: integer
10153+
nodeAffinityPolicy:
10154+
type: string
10155+
nodeTaintsPolicy:
10156+
type: string
10157+
topologyKey:
10158+
type: string
10159+
whenUnsatisfiable:
10160+
type: string
10161+
required:
10162+
- maxSkew
10163+
- topologyKey
10164+
- whenUnsatisfiable
10165+
type: object
10166+
type: array
1011510167
volumeClaimTemplates:
1011610168
properties:
1011710169
accessModes:
@@ -13605,6 +13657,58 @@ spec:
1360513657
type: string
1360613658
type: object
1360713659
type: array
13660+
topologySpreadConstraints:
13661+
items:
13662+
properties:
13663+
labelSelector:
13664+
properties:
13665+
matchExpressions:
13666+
items:
13667+
properties:
13668+
key:
13669+
type: string
13670+
operator:
13671+
type: string
13672+
values:
13673+
items:
13674+
type: string
13675+
type: array
13676+
required:
13677+
- key
13678+
- operator
13679+
type: object
13680+
type: array
13681+
matchLabels:
13682+
additionalProperties:
13683+
type: string
13684+
type: object
13685+
type: object
13686+
x-kubernetes-map-type: atomic
13687+
matchLabelKeys:
13688+
items:
13689+
type: string
13690+
type: array
13691+
x-kubernetes-list-type: atomic
13692+
maxSkew:
13693+
format: int32
13694+
type: integer
13695+
minDomains:
13696+
format: int32
13697+
type: integer
13698+
nodeAffinityPolicy:
13699+
type: string
13700+
nodeTaintsPolicy:
13701+
type: string
13702+
topologyKey:
13703+
type: string
13704+
whenUnsatisfiable:
13705+
type: string
13706+
required:
13707+
- maxSkew
13708+
- topologyKey
13709+
- whenUnsatisfiable
13710+
type: object
13711+
type: array
1360813712
type: object
1360913713
type: object
1361013714
revisionHistoryLimit:

0 commit comments

Comments
 (0)