Skip to content

Commit

Permalink
feat: add topologySpreadConstraints for emqx CRD (#1042)
Browse files Browse the repository at this point in the history
fix: #1041
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z authored Apr 17, 2024
1 parent 20b8df4 commit 40cbff1
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 8 deletions.
2 changes: 2 additions & 0 deletions apis/apps/v2beta1/emqx_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ type EMQXReplicantTemplateSpec struct {
// If specified, the pod's tolerations.
// The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator .
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
//// TopologySpreadConstraint specifies how to spread matching pods among the given topology.
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// Replicas is the desired number of replicas of the given Template.
// These are replicas in the sense that they are instantiations of the
// same Template, but individual replicas also have a consistent identity.
Expand Down
7 changes: 7 additions & 0 deletions apis/apps/v2beta1/zz_generated.deepcopy.go

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

104 changes: 104 additions & 0 deletions config/crd/bases/apps.emqx.io_emqxes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10100,6 +10100,58 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
volumeClaimTemplates:
properties:
accessModes:
Expand Down Expand Up @@ -13593,6 +13645,58 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
type: object
type: object
revisionHistoryLimit:
Expand Down
7 changes: 4 additions & 3 deletions controllers/apps/v2beta1/add_emqx_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ func generateStatefulSet(instance *appsv2beta1.EMQX) *appsv1.StatefulSet {
// TODO: just for compatible with old version, will remove in future
instance.Spec.CoreTemplate.Spec.ToleRations...,
),
NodeName: instance.Spec.CoreTemplate.Spec.NodeName,
NodeSelector: instance.Spec.CoreTemplate.Spec.NodeSelector,
InitContainers: instance.Spec.CoreTemplate.Spec.InitContainers,
TopologySpreadConstraints: instance.Spec.CoreTemplate.Spec.TopologySpreadConstraints,
NodeName: instance.Spec.CoreTemplate.Spec.NodeName,
NodeSelector: instance.Spec.CoreTemplate.Spec.NodeSelector,
InitContainers: instance.Spec.CoreTemplate.Spec.InitContainers,
Containers: append([]corev1.Container{
{
Name: appsv2beta1.DefaultContainerName,
Expand Down
7 changes: 4 additions & 3 deletions controllers/apps/v2beta1/add_emqx_repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ func generateReplicaSet(instance *appsv2beta1.EMQX) *appsv1.ReplicaSet {
// TODO: just for compatible with old version, will remove in future
instance.Spec.ReplicantTemplate.Spec.ToleRations...,
),
NodeName: instance.Spec.ReplicantTemplate.Spec.NodeName,
NodeSelector: instance.Spec.ReplicantTemplate.Spec.NodeSelector,
InitContainers: instance.Spec.ReplicantTemplate.Spec.InitContainers,
TopologySpreadConstraints: instance.Spec.CoreTemplate.Spec.TopologySpreadConstraints,
NodeName: instance.Spec.ReplicantTemplate.Spec.NodeName,
NodeSelector: instance.Spec.ReplicantTemplate.Spec.NodeSelector,
InitContainers: instance.Spec.ReplicantTemplate.Spec.InitContainers,
Containers: append([]corev1.Container{
{
Name: appsv2beta1.DefaultContainerName,
Expand Down
4 changes: 2 additions & 2 deletions deploy/charts/emqx-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.2.20
version: 2.2.21

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

sources:
- https://github.com/emqx/emqx-operator/tree/main/deploy/charts/emqx-operator
Expand Down
104 changes: 104 additions & 0 deletions deploy/charts/emqx-operator/templates/crd.emqxes.apps.emqx.io.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10112,6 +10112,58 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
volumeClaimTemplates:
properties:
accessModes:
Expand Down Expand Up @@ -13605,6 +13657,58 @@ spec:
type: string
type: object
type: array
topologySpreadConstraints:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
type: object
type: object
revisionHistoryLimit:
Expand Down
Loading

0 comments on commit 40cbff1

Please sign in to comment.