diff --git a/controllers/defaults/placements.go b/controllers/defaults/placements.go index df4821fa5a..4ac96508dd 100644 --- a/controllers/defaults/placements.go +++ b/controllers/defaults/placements.go @@ -7,6 +7,8 @@ import ( ) var ( + ProviderServerKey = "provider-server" + // osdLabelSelector is the key in OSD pod. Used // as a label selector for topology spread constraints. osdLabelSelector = "rook-ceph-osd" @@ -126,6 +128,12 @@ var ( getOcsToleration(), }, }, + + ProviderServerKey: { + Tolerations: []corev1.Toleration{ + getOcsToleration(), + }, + }, } ) diff --git a/controllers/storagecluster/placement.go b/controllers/storagecluster/placement.go index f11cd44503..7ee2f5cbec 100644 --- a/controllers/storagecluster/placement.go +++ b/controllers/storagecluster/placement.go @@ -38,6 +38,12 @@ func getPlacement(sc *ocsv1.StorageCluster, component string) rookCephv1.Placeme return placement } + // if provider-server placements are found in the storagecluster spec append the default ocs tolerations to it + if ok && component == defaults.ProviderServerKey { + 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. diff --git a/controllers/storagecluster/provider_server.go b/controllers/storagecluster/provider_server.go index 8516abc57c..41f118b73d 100644 --- a/controllers/storagecluster/provider_server.go +++ b/controllers/storagecluster/provider_server.go @@ -22,6 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" 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/controllers/util" "github.com/red-hat-storage/ocs-operator/v4/services/provider/server" ) @@ -379,6 +380,7 @@ func GetProviderAPIServerDeployment(instance *ocsv1.StorageCluster) *appsv1.Depl }, }, }, + Tolerations: getPlacement(instance, defaults.ProviderServerKey).Tolerations, ServiceAccountName: ocsProviderServerName, }, }, diff --git a/controllers/storagecluster/provider_server_test.go b/controllers/storagecluster/provider_server_test.go index 8520390d2b..b6b24a1d1b 100644 --- a/controllers/storagecluster/provider_server_test.go +++ b/controllers/storagecluster/provider_server_test.go @@ -17,6 +17,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" 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/controllers/util" "github.com/red-hat-storage/ocs-operator/v4/services/provider/server" ) @@ -393,6 +394,7 @@ func GetProviderAPIServerDeploymentForTest(instance *ocsv1.StorageCluster) *apps }, }, ServiceAccountName: ocsProviderServerName, + Tolerations: getPlacement(instance, defaults.ProviderServerKey).Tolerations, }, }, },