From f5a3f6fa71b922bc8a348cb532d86b4da0539294 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Mon, 15 Mar 2021 18:01:12 +0530 Subject: [PATCH] ceph: add option to toggle host networking in csi plugin pods As host networking is no longer necessary for CSI driver, it will be disabled by default. An option CSI_ENABLE_HOST_NETWORK is added to rook-ceph-operator-config configmap and enableCSIHostNetwork in helm chart values.yaml to enable/disable host network in CSI plugin pods. Closes: #7203 Signed-off-by: Rakshith R --- Documentation/helm-operator.md | 1 + cluster/charts/rook-ceph/templates/deployment.yaml | 4 ++++ cluster/charts/rook-ceph/values.yaml | 4 ++++ .../ceph/csi/template/cephfs/csi-cephfsplugin.yaml | 2 +- .../kubernetes/ceph/csi/template/rbd/csi-rbdplugin.yaml | 2 +- cluster/examples/kubernetes/ceph/operator-openshift.yaml | 5 +++++ cluster/examples/kubernetes/ceph/operator.yaml | 5 +++++ pkg/operator/ceph/csi/csi.go | 8 ++++++++ pkg/operator/ceph/csi/spec.go | 1 + 9 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Documentation/helm-operator.md b/Documentation/helm-operator.md index 1734878b7..884d16846 100644 --- a/Documentation/helm-operator.md +++ b/Documentation/helm-operator.md @@ -110,6 +110,7 @@ The following tables lists the configurable parameters of the rook-operator char | `csi.cephFSFSGroupPolicy` | Policy for modifying a volume's ownership or permissions when the CephFS PVC is being mounted | ReadWriteOnceWithFSType | | `csi.logLevel` | Set logging level for csi containers. Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. | `0` | | `csi.enableGrpcMetrics` | Enable Ceph CSI GRPC Metrics. | `false` | +| `csi.enableCSIHostNetwork` | Enable Host Networking for Ceph CSI nodeplugins. | `false` | | `csi.provisionerTolerations` | Array of tolerations in YAML format which will be added to CSI provisioner deployment. | | | `csi.provisionerNodeAffinity` | The node labels for affinity of the CSI provisioner deployment (***) | | | `csi.pluginTolerations` | Array of tolerations in YAML format which will be added to Ceph CSI plugin DaemonSet | | diff --git a/cluster/charts/rook-ceph/templates/deployment.yaml b/cluster/charts/rook-ceph/templates/deployment.yaml index 29bf59637..c9e03652c 100644 --- a/cluster/charts/rook-ceph/templates/deployment.yaml +++ b/cluster/charts/rook-ceph/templates/deployment.yaml @@ -122,6 +122,10 @@ spec: value: {{ .Values.csi.enableOMAPGenerator | quote }} - name: CSI_ENABLE_VOLUME_REPLICATION value: {{ .Values.csi.volumeReplication.enabled | quote }} +{{- if .Values.csi.enableCSIHostNetwork }} + - name: CSI_ENABLE_HOST_NETWORK + value: {{ .Values.csi.enableCSIHostNetwork | quote }} +{{- end }} {{- if .Values.csi.cephFSPluginUpdateStrategy }} - name: CSI_CEPHFS_PLUGIN_UPDATE_STRATEGY value: {{ .Values.csi.cephFSPluginUpdateStrategy | quote }} diff --git a/cluster/charts/rook-ceph/values.yaml b/cluster/charts/rook-ceph/values.yaml index a5f5fecec..af57799eb 100644 --- a/cluster/charts/rook-ceph/values.yaml +++ b/cluster/charts/rook-ceph/values.yaml @@ -56,6 +56,10 @@ csi: enableRbdDriver: true enableCephfsDriver: true enableGrpcMetrics: false + # Set to true to enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary + # in some network configurations where the SDN does not provide access to an external cluster or + # there is significant drop in read/write performance. + # CSI_ENABLE_HOST_NETWORK: "true" # set to false to disable deployment of snapshotter container in CephFS provisioner pod. enableCephfsSnapshotter: true # set to false to disable deployment of snapshotter container in RBD provisioner pod. diff --git a/cluster/examples/kubernetes/ceph/csi/template/cephfs/csi-cephfsplugin.yaml b/cluster/examples/kubernetes/ceph/csi/template/cephfs/csi-cephfsplugin.yaml index bd8a40118..6d1d811fd 100644 --- a/cluster/examples/kubernetes/ceph/csi/template/cephfs/csi-cephfsplugin.yaml +++ b/cluster/examples/kubernetes/ceph/csi/template/cephfs/csi-cephfsplugin.yaml @@ -19,7 +19,7 @@ spec: {{ end }} spec: serviceAccount: rook-csi-cephfs-plugin-sa - hostNetwork: true + hostNetwork: {{ .EnableCSIHostNetwork }} {{ if .PluginPriorityClassName }} priorityClassName: {{ .PluginPriorityClassName }} {{ end }} diff --git a/cluster/examples/kubernetes/ceph/csi/template/rbd/csi-rbdplugin.yaml b/cluster/examples/kubernetes/ceph/csi/template/rbd/csi-rbdplugin.yaml index 271125a08..1d1c9bfe1 100644 --- a/cluster/examples/kubernetes/ceph/csi/template/rbd/csi-rbdplugin.yaml +++ b/cluster/examples/kubernetes/ceph/csi/template/rbd/csi-rbdplugin.yaml @@ -22,7 +22,7 @@ spec: {{ if .PluginPriorityClassName }} priorityClassName: {{ .PluginPriorityClassName }} {{ end }} - hostNetwork: true + hostNetwork: {{ .EnableCSIHostNetwork }} hostPID: true # to use e.g. Rook orchestrated cluster, and mons' FQDN is # resolved through k8s service, set dns policy to cluster first diff --git a/cluster/examples/kubernetes/ceph/operator-openshift.yaml b/cluster/examples/kubernetes/ceph/operator-openshift.yaml index 49456446d..d13ebb861 100644 --- a/cluster/examples/kubernetes/ceph/operator-openshift.yaml +++ b/cluster/examples/kubernetes/ceph/operator-openshift.yaml @@ -105,6 +105,11 @@ data: ROOK_CSI_ENABLE_RBD: "true" ROOK_CSI_ENABLE_GRPC_METRICS: "false" + # Set to true to enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary + # in some network configurations where the SDN does not provide access to an external cluster or + # there is significant drop in read/write performance. + # CSI_ENABLE_HOST_NETWORK: "true" + # Set logging level for csi containers. # Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. # CSI_LOG_LEVEL: "0" diff --git a/cluster/examples/kubernetes/ceph/operator.yaml b/cluster/examples/kubernetes/ceph/operator.yaml index cf2933580..4ff23aae5 100644 --- a/cluster/examples/kubernetes/ceph/operator.yaml +++ b/cluster/examples/kubernetes/ceph/operator.yaml @@ -29,6 +29,11 @@ data: ROOK_CSI_ENABLE_RBD: "true" ROOK_CSI_ENABLE_GRPC_METRICS: "false" + # Set to true to enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary + # in some network configurations where the SDN does not provide access to an external cluster or + # there is significant drop in read/write performance. + # CSI_ENABLE_HOST_NETWORK: "true" + # Set logging level for csi containers. # Supported values from 0 to 5. 0 for general useful logs, 5 for trace level verbosity. # CSI_LOG_LEVEL: "0" diff --git a/pkg/operator/ceph/csi/csi.go b/pkg/operator/ceph/csi/csi.go index b0364a171..7c929a282 100644 --- a/pkg/operator/ceph/csi/csi.go +++ b/pkg/operator/ceph/csi/csi.go @@ -84,6 +84,14 @@ func SetParams(clientset kubernetes.Interface) error { return errors.Wrap(err, "unable to parse value for 'ROOK_CSI_ENABLE_GRPC_METRICS'") } + csiEnableCSIHostNetwork, err := k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "CSI_ENABLE_HOST_NETWORK", "false") + if err != nil { + return errors.Wrap(err, "failed to determine if CSI Host Network is enabled") + } + if CSIParam.EnableCSIHostNetwork, err = strconv.ParseBool(csiEnableCSIHostNetwork); err != nil { + return errors.Wrap(err, "failed to parse value for 'CSI_ENABLE_HOST_NETWORK'") + } + CSIParam.CSIPluginImage, err = k8sutil.GetOperatorSetting(clientset, controllerutil.OperatorSettingConfigMapName, "ROOK_CSI_CEPH_IMAGE", DefaultCSIPluginImage) if err != nil { return errors.Wrap(err, "unable to configure CSI plugin image") diff --git a/pkg/operator/ceph/csi/spec.go b/pkg/operator/ceph/csi/spec.go index 19bf420dd..c86c7adcd 100644 --- a/pkg/operator/ceph/csi/spec.go +++ b/pkg/operator/ceph/csi/spec.go @@ -55,6 +55,7 @@ type Param struct { PluginPriorityClassName string ProvisionerPriorityClassName string VolumeReplicationImage string + EnableCSIHostNetwork bool EnableOMAPGenerator bool EnableRBDSnapshotter bool EnableCephFSSnapshotter bool