Skip to content

Commit

Permalink
csi: adding toleration to schedule CSI pods
Browse files Browse the repository at this point in the history
when PVC is scheduled on master node csi pods
fail to run on master nodes

Signed-off-by: rchikatw <[email protected]>
  • Loading branch information
rchikatw committed Nov 15, 2023
1 parent 1969a71 commit 9b642c4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/csi/cephfsdaemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"

"github.com/red-hat-storage/ocs-client-operator/pkg/templates"
"github.com/red-hat-storage/ocs-client-operator/pkg/utils"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -262,6 +263,9 @@ func GetCephFSDaemonSet(namespace string) *appsv1.DaemonSet {
},
},
},
Tolerations: []corev1.Toleration{
utils.GetTolerationForCSIPods(),
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions pkg/csi/rbddaemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"fmt"

"github.com/red-hat-storage/ocs-client-operator/pkg/templates"
"github.com/red-hat-storage/ocs-client-operator/pkg/utils"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -390,6 +391,9 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet {
},
},
},
Tolerations: []corev1.Toleration{
utils.GetTolerationForCSIPods(),
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const StorageClientNamespaceEnvVar = "STORAGE_CLIENT_NAMESPACE"

const StatusReporterImageEnvVar = "STATUS_REPORTER_IMAGE"

const CSIDaemonSetsTolerateAllNodes = "CSI_DaemonSets_Tolerate_All_Nodes"

// GetOperatorNamespace returns the namespace where the operator is deployed.
func GetOperatorNamespace() string {
return os.Getenv(OperatorNamespaceEnvVar)
Expand Down
27 changes: 27 additions & 0 deletions pkg/utils/placements.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package utils

import (
"log"
"os"
"strconv"

corev1 "k8s.io/api/core/v1"
)

func GetTolerationForCSIPods() corev1.Toleration {
enableCSIPodSchedulingOnMaster, err := strconv.ParseBool(os.Getenv(CSIDaemonSetsTolerateAllNodes))
if err != nil {
log.Fatal(err)
}
if enableCSIPodSchedulingOnMaster {
toleration := corev1.Toleration{
Key: "node-role.kubernetes.io/master",
Operator: corev1.TolerationOpExists,
Value: "true",
Effect: corev1.TaintEffectNoSchedule,
}
return toleration

}
return corev1.Toleration{}
}

0 comments on commit 9b642c4

Please sign in to comment.