Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2247735: Adding toleration to schedule CSI pods on master nodes #40

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 runCSIDaemonsetOnMaster = "RUN_CSI_DAEMONSET_ON_MASTER"

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

import (
"log"
"os"
"strconv"

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

func GetTolerationForCSIPods() corev1.Toleration {

runOnMaster := true
var err error
rom := os.Getenv(runCSIDaemonsetOnMaster)
if rom != "" {
runOnMaster, err = strconv.ParseBool(rom)
if err != nil {
log.Fatal(err)
}
}

if runOnMaster {
toleration := corev1.Toleration{
Key: "node-role.kubernetes.io/master",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this is deprecated and replaced with control-plane https://kubernetes.io/docs/reference/labels-annotations-taints/#node-role-kubernetes-io-master-taint, please check what we have in supported OCP versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked one of the fusion hci clusters the key was "node-role.kubernetes.io/master". we can go with this key

Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
}
return toleration
}
return corev1.Toleration{}
}
Loading