diff --git a/cluster/charts/rook-ceph/templates/deployment.yaml b/cluster/charts/rook-ceph/templates/deployment.yaml index bd4bc50d0..6aebcfb1e 100644 --- a/cluster/charts/rook-ceph/templates/deployment.yaml +++ b/cluster/charts/rook-ceph/templates/deployment.yaml @@ -77,6 +77,10 @@ spec: value: {{ .Values.logLevel }} - name: ROOK_ENABLE_SELINUX_RELABELING value: {{ .Values.enableSelinuxRelabeling | quote }} +{{- if .Values.disableDeviceHotplug }} + - name: ROOK_DISABLE_DEVICE_HOTPLUG + value: {{ .Values.disableDeviceHotplug }} +{{- end }} - name: NODE_NAME valueFrom: fieldRef: diff --git a/cluster/charts/rook-ceph/values.yaml.tmpl b/cluster/charts/rook-ceph/values.yaml.tmpl index 0aff153d5..95db6dbff 100644 --- a/cluster/charts/rook-ceph/values.yaml.tmpl +++ b/cluster/charts/rook-ceph/values.yaml.tmpl @@ -79,3 +79,6 @@ enableSelinuxRelabeling: true # Writing to the hostPath is required for the Ceph mon and osd pods. Given the restricted permissions in OpenShift with SELinux, # the pod must be running privileged in order to write to the hostPath volume, this must be set to true then. hostpathRequiresPrivileged: false + +# Disable automatic orchestration when new devices are discovered. +disableDeviceHotplug: false diff --git a/cluster/examples/kubernetes/ceph/operator-openshift.yaml b/cluster/examples/kubernetes/ceph/operator-openshift.yaml index bcea69ec9..5c59a73ca 100644 --- a/cluster/examples/kubernetes/ceph/operator-openshift.yaml +++ b/cluster/examples/kubernetes/ceph/operator-openshift.yaml @@ -150,6 +150,9 @@ spec: # For more details see https://github.com/rook/rook/issues/2254 - name: ROOK_ENABLE_FSGROUP value: "true" + # Disable automatic orchestration when new devices are discovered + - name: ROOK_DISABLE_DEVICE_HOTPLUG + value: "false" # The name of the node to pass with the downward API - name: NODE_NAME valueFrom: diff --git a/cluster/examples/kubernetes/ceph/operator.yaml b/cluster/examples/kubernetes/ceph/operator.yaml index ff63bd489..43d5ccd6b 100644 --- a/cluster/examples/kubernetes/ceph/operator.yaml +++ b/cluster/examples/kubernetes/ceph/operator.yaml @@ -113,6 +113,9 @@ spec: # For more details see https://github.com/rook/rook/issues/2254 - name: ROOK_ENABLE_FSGROUP value: "true" + # Disable automatic orchestration when new devices are discovered + - name: ROOK_DISABLE_DEVICE_HOTPLUG + value: "false" # The name of the node to pass with the downward API - name: NODE_NAME valueFrom: diff --git a/pkg/operator/ceph/cluster/controller.go b/pkg/operator/ceph/cluster/controller.go index 430e8b50b..6400b66e9 100644 --- a/pkg/operator/ceph/cluster/controller.go +++ b/pkg/operator/ceph/cluster/controller.go @@ -63,6 +63,7 @@ const ( DefaultClusterName = "rook-ceph" clusterDeleteRetryInterval = 2 //seconds clusterDeleteMaxRetries = 15 + disableHotplugEnv = "ROOK_DISABLE_DEVICE_HOTPLUG" ) var ( @@ -143,24 +144,29 @@ func (c *ClusterController) StartWatch(namespace string, stopCh chan struct{}) e ) go nodeController.Run(stopCh) - // watch for updates to the device discovery configmap - operatorNamespace := os.Getenv(k8sutil.PodNamespaceEnvVar) - _, deviceCMController := cache.NewInformer( - cache.NewFilteredListWatchFromClient(c.context.Clientset.CoreV1().RESTClient(), - "configmaps", operatorNamespace, func(options *metav1.ListOptions) { - options.LabelSelector = fmt.Sprintf("%s=%s", k8sutil.AppAttr, discoverDaemon.AppName) + if disableVal := os.Getenv(disableHotplugEnv); disableVal != "true" { + // watch for updates to the device discovery configmap + logger.Infof("Enabling hotplug orchestration: %s=%s", disableHotplugEnv, disableVal) + operatorNamespace := os.Getenv(k8sutil.PodNamespaceEnvVar) + _, deviceCMController := cache.NewInformer( + cache.NewFilteredListWatchFromClient(c.context.Clientset.CoreV1().RESTClient(), + "configmaps", operatorNamespace, func(options *metav1.ListOptions) { + options.LabelSelector = fmt.Sprintf("%s=%s", k8sutil.AppAttr, discoverDaemon.AppName) + }, + ), + &v1.ConfigMap{}, + 0, + cache.ResourceEventHandlerFuncs{ + AddFunc: nil, + UpdateFunc: c.onDeviceCMUpdate, + DeleteFunc: nil, }, - ), - &v1.ConfigMap{}, - 0, - cache.ResourceEventHandlerFuncs{ - AddFunc: nil, - UpdateFunc: c.onDeviceCMUpdate, - DeleteFunc: nil, - }, - ) + ) - go deviceCMController.Run(stopCh) + go deviceCMController.Run(stopCh) + } else { + logger.Infof("Disabling hotplug orchestration via %s", disableHotplugEnv) + } // watch for events on all legacy types too c.watchLegacyClusters(namespace, stopCh, resourceHandlerFuncs)