Skip to content

Commit

Permalink
Add mechanism for adding tolerations on metrics exporter
Browse files Browse the repository at this point in the history
Signed-off-by: Nitin Goyal <[email protected]>
  • Loading branch information
iamniting committed Mar 15, 2024
1 parent 719e470 commit 76b14db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion controllers/defaults/placements.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
)

var (
ProviderServerKey = "provider-server"
ProviderServerKey = "provider-server"
MetricsExporterKey = "metrics-exporter"

// osdLabelSelector is the key in OSD pod. Used
// as a label selector for topology spread constraints.
Expand Down Expand Up @@ -134,6 +135,12 @@ var (
getOcsToleration(),
},
},

MetricsExporterKey: {
Tolerations: []corev1.Toleration{
getOcsToleration(),
},
},
}
)

Expand Down
2 changes: 2 additions & 0 deletions controllers/storagecluster/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/imdario/mergo"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
"github.com/red-hat-storage/ocs-operator/v4/controllers/defaults"
"github.com/red-hat-storage/ocs-operator/v4/version"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -351,6 +352,7 @@ func deployMetricsExporter(ctx context.Context, r *StorageClusterReconciler, ins
},
},
}},
Tolerations: getPlacement(instance, defaults.MetricsExporterKey).Tolerations,
},
}
return nil
Expand Down
6 changes: 6 additions & 0 deletions controllers/storagecluster/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ func getPlacement(sc *ocsv1.StorageCluster, component string) rookCephv1.Placeme
return placement
}

// if metrics-exporter placements are found in the storagecluster spec append the default ocs tolerations to it
if ok && component == defaults.MetricsExporterKey {
placement.Tolerations = append(placement.Tolerations, defaults.DaemonPlacements[component].Tolerations...)
return placement
}

// If no placement is specified for the given component and the
// StorageCluster has no label selector, set the default node
// affinity.
Expand Down

0 comments on commit 76b14db

Please sign in to comment.