Skip to content

Commit 7ed7521

Browse files
authored
Merge pull request #1653 from dannyzaken/danny-fixes
Added TopologyKey to noobaa CRD for multizone support
2 parents 5488c39 + 2ff0273 commit 7ed7521

File tree

9 files changed

+134
-39
lines changed

9 files changed

+134
-39
lines changed

deploy/crds/noobaa.io_noobaas.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,11 @@ spec:
984984
type: array
985985
x-kubernetes-list-type: atomic
986986
type: object
987+
topologyKey:
988+
description: |-
989+
TopologyKey (optional) the TopologyKey to pass as the domain for TopologySpreadConstraint and Affinity of noobaa components
990+
It is used by the endpoints and the DB pods to control pods distribution between topology domains (host/zone)
991+
type: string
987992
type: object
988993
annotations:
989994
additionalProperties:

pkg/apis/noobaa/v1alpha1/noobaa_types.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ type NooBaaSpec struct {
157157

158158
// Affinity (optional) passed through to noobaa's pods
159159
// +optional
160-
Affinity *corev1.Affinity `json:"affinity,omitempty"`
160+
Affinity *AffinitySpec `json:"affinity,omitempty"`
161161

162162
// ImagePullSecret (optional) sets a pull secret for the system image
163163
// +optional
@@ -242,6 +242,24 @@ type NooBaaSpec struct {
242242
BucketNotifications BucketNotificationsSpec `json:"bucketNotifications,omitempty"`
243243
}
244244

245+
// Affinity is a group of affinity scheduling rules.
246+
type AffinitySpec struct {
247+
// Describes node affinity scheduling rules for the pod.
248+
// +optional
249+
NodeAffinity *corev1.NodeAffinity `json:"nodeAffinity,omitempty" protobuf:"bytes,1,opt,name=nodeAffinity"`
250+
// Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)).
251+
// +optional
252+
PodAffinity *corev1.PodAffinity `json:"podAffinity,omitempty" protobuf:"bytes,2,opt,name=podAffinity"`
253+
// Describes pod anti-affinity scheduling rules (e.g. avoid putting this pod in the same node, zone, etc. as some other pod(s)).
254+
// +optional
255+
PodAntiAffinity *corev1.PodAntiAffinity `json:"podAntiAffinity,omitempty" protobuf:"bytes,3,opt,name=podAntiAffinity"`
256+
257+
// TopologyKey (optional) the TopologyKey to pass as the domain for TopologySpreadConstraint and Affinity of noobaa components
258+
// It is used by the endpoints and the DB pods to control pods distribution between topology domains (host/zone)
259+
// +optional
260+
TopologyKey string `json:"topologyKey,omitempty"`
261+
}
262+
245263
// AutoscalerSpec defines different actoscaling spec such as autoscaler type and prometheus namespace
246264
type AutoscalerSpec struct {
247265
// Type of autoscaling (optional) for noobaa-endpoint, hpav2(default) and keda - Prometheus metrics based
@@ -640,7 +658,7 @@ const (
640658
// DeleteOBCConfirmation represents the validation to destry obc
641659
DeleteOBCConfirmation CleanupConfirmationProperty = "yes-really-destroy-obc"
642660

643-
// SkipTopologyConstraints is Annotation name for disabling default topology Constraints
661+
// SkipTopologyConstraints is Annotation name for skipping the reconciliation of the default topology Constraints
644662
SkipTopologyConstraints = "noobaa.io/skip_topology_spread_constraints"
645663

646664
// DisableDBDefaultMonitoring is Annotation name for disabling default db monitoring

pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go

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

pkg/backingstore/reconciler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,11 @@ func (r *Reconciler) updatePodTemplate() error {
13291329
r.PodAgentTemplate.Spec.Tolerations = r.NooBaa.Spec.Tolerations
13301330
}
13311331
if r.NooBaa.Spec.Affinity != nil {
1332-
r.PodAgentTemplate.Spec.Affinity = r.NooBaa.Spec.Affinity
1332+
r.PodAgentTemplate.Spec.Affinity = &corev1.Affinity{
1333+
NodeAffinity: r.NooBaa.Spec.Affinity.NodeAffinity,
1334+
PodAffinity: r.NooBaa.Spec.Affinity.PodAffinity,
1335+
PodAntiAffinity: r.NooBaa.Spec.Affinity.PodAntiAffinity,
1336+
}
13331337
}
13341338

13351339
if !util.HasNodeInclusionPolicyInPodTopologySpread() {

pkg/bundle/deploy.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ spec:
14231423
status: {}
14241424
`
14251425

1426-
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "1637077ca2e0d584cd4203469f809b215af45ee4ba5358a283bbd7a5bf1b573e"
1426+
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "9aed761f69a7c552dd6c2dfc558fd055d6c236765a0728b9a39abf289827668f"
14271427

14281428
const File_deploy_crds_noobaa_io_noobaas_yaml = `---
14291429
apiVersion: apiextensions.k8s.io/v1
@@ -2411,6 +2411,11 @@ spec:
24112411
type: array
24122412
x-kubernetes-list-type: atomic
24132413
type: object
2414+
topologyKey:
2415+
description: |-
2416+
TopologyKey (optional) the TopologyKey to pass as the domain for TopologySpreadConstraint and Affinity of noobaa components
2417+
It is used by the endpoints and the DB pods to control pods distribution between topology domains (host/zone)
2418+
type: string
24142419
type: object
24152420
annotations:
24162421
additionalProperties:

pkg/system/db_reconciler.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ func (r *Reconciler) reconcileClusterSpec(dbSpec *nbv1.NooBaaDBSpec) error {
248248
// set tolerations and node affinity to the cluster spec
249249
if r.NooBaa.Spec.Affinity != nil {
250250
r.CNPGCluster.Spec.Affinity.NodeAffinity = r.NooBaa.Spec.Affinity.NodeAffinity
251+
if r.NooBaa.Spec.Affinity.TopologyKey != "" {
252+
r.CNPGCluster.Spec.Affinity.TopologyKey = r.NooBaa.Spec.Affinity.TopologyKey
253+
}
254+
} else {
255+
r.CNPGCluster.Spec.Affinity.NodeAffinity = nil
256+
r.CNPGCluster.Spec.Affinity.TopologyKey = ""
251257
}
252258
if r.NooBaa.Spec.Tolerations != nil {
253259
r.CNPGCluster.Spec.Affinity.Tolerations = r.NooBaa.Spec.Tolerations
@@ -517,6 +523,7 @@ func (r *Reconciler) wasClusterSpecChanged(existingClusterSpec *cnpgv1.ClusterSp
517523
return !reflect.DeepEqual(existingClusterSpec.InheritedMetadata, r.CNPGCluster.Spec.InheritedMetadata) ||
518524
!reflect.DeepEqual(existingClusterSpec.ImageCatalogRef, r.CNPGCluster.Spec.ImageCatalogRef) ||
519525
existingClusterSpec.Instances != r.CNPGCluster.Spec.Instances ||
526+
!reflect.DeepEqual(existingClusterSpec.Affinity, r.CNPGCluster.Spec.Affinity) ||
520527
!reflect.DeepEqual(existingClusterSpec.Resources, r.CNPGCluster.Spec.Resources) ||
521528
!reflect.DeepEqual(existingClusterSpec.StorageConfiguration.StorageClass, r.CNPGCluster.Spec.StorageConfiguration.StorageClass) ||
522529
!reflect.DeepEqual(existingClusterSpec.StorageConfiguration.Size, r.CNPGCluster.Spec.StorageConfiguration.Size) ||

pkg/system/phase2_creating.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (r *Reconciler) SetDesiredNooBaaDB() error {
333333
[]corev1.LocalObjectReference{*r.NooBaa.Spec.ImagePullSecret}
334334
}
335335
podSpec.Tolerations = r.NooBaa.Spec.Tolerations
336-
podSpec.Affinity = r.NooBaa.Spec.Affinity
336+
podSpec.Affinity = r.GetAffinity()
337337

338338
if NooBaaDB.UID == "" {
339339
for i := range NooBaaDB.Spec.VolumeClaimTemplates {
@@ -704,7 +704,7 @@ func (r *Reconciler) SetDesiredCoreApp() error {
704704
[]corev1.LocalObjectReference{*r.NooBaa.Spec.ImagePullSecret}
705705
}
706706
podSpec.Tolerations = r.NooBaa.Spec.Tolerations
707-
podSpec.Affinity = r.NooBaa.Spec.Affinity
707+
podSpec.Affinity = r.GetAffinity()
708708

709709
if r.CoreApp.UID == "" {
710710
// generate info event for the first creation of noobaa

0 commit comments

Comments
 (0)