Skip to content

Commit

Permalink
helm: CSIDriver add labels and seLinuxMount disabling method
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Khizhnyak <rkhizhnyak@ptsecurity.com>
  • Loading branch information
Ruslan Khizhnyak authored and mergify[bot] committed Mar 21, 2024
1 parent cd18490 commit d56c9ab
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
10 changes: 8 additions & 2 deletions charts/ceph-csi-cephfs/templates/csidriver-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: {{ .Values.driverName }}
labels:
app: {{ include "ceph-csi-cephfs.name" . }}
chart: {{ include "ceph-csi-cephfs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
spec:
attachRequired: false
podInfoOnMount: false
fsGroupPolicy: {{ default "File" .Values.CSIDriver.fsGroupPolicy }}
{{- if semverCompare ">= 1.25.x" .Capabilities.KubeVersion.Version }}
fsGroupPolicy: {{ .Values.CSIDriver.fsGroupPolicy }}
{{- if and (semverCompare ">= 1.25.x" .Capabilities.KubeVersion.Version) .Values.seLinuxMount }}
seLinuxMount: true
{{- end }}
1 change: 1 addition & 0 deletions charts/ceph-csi-cephfs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ sidecarLogLevel: 1
# accessModes contains ReadWriteOnce.
CSIDriver:
fsGroupPolicy: "File"
seLinuxMount: true

nodeplugin:
name: nodeplugin
Expand Down
10 changes: 8 additions & 2 deletions charts/ceph-csi-rbd/templates/csidriver-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: {{ .Values.driverName }}
labels:
app: {{ include "ceph-csi-rbd.name" . }}
chart: {{ include "ceph-csi-rbd.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
spec:
attachRequired: true
podInfoOnMount: false
fsGroupPolicy: File
{{- if semverCompare ">= 1.25.x" .Capabilities.KubeVersion.Version }}
fsGroupPolicy: {{ .Values.CSIDriver.fsGroupPolicy }}
{{- if and (semverCompare ">= 1.25.x" .Capabilities.KubeVersion.Version) .Values.seLinuxMount }}
seLinuxMount: true
{{- end }}
18 changes: 18 additions & 0 deletions charts/ceph-csi-rbd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ logLevel: 5
# sidecarLogLevel is the variable for Kubernetes sidecar container's log level
sidecarLogLevel: 1

# Set fsGroupPolicy for CSI Driver object spec
# https://kubernetes-csi.github.io/docs/support-fsgroup.html
# The following modes are supported:
# - None: Indicates that volumes will be mounted with no modifications, as the
# CSI volume driver does not support these operations.
# - File: Indicates that the CSI volume driver supports volume ownership and
# permission change via fsGroup, and Kubernetes may use fsGroup to change
# permissions and ownership of the volume to match user requested fsGroup in
# the pod's SecurityPolicy regardless of fstype or access mode.
# - ReadWriteOnceWithFSType: Indicates that volumes will be examined to
# determine if volume ownership and permissions should be modified to match
# the pod's security policy.
# Changes will only occur if the fsType is defined and the persistent volume's
# accessModes contains ReadWriteOnce.
CSIDriver:
fsGroupPolicy: "File"
seLinuxMount: true

nodeplugin:
name: nodeplugin
# set user created priorityclassName for csi plugin pods. default is
Expand Down

3 comments on commit d56c9ab

@Velociraptor85
Copy link

@Velociraptor85 Velociraptor85 commented on d56c9ab Mar 26, 2024

Choose a reason for hiding this comment

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

@nixpanic
Copy link
Member

Choose a reason for hiding this comment

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

When .Values.selinuxMount is enabled, it makes sense that the CSIDriver should also have its seLinuxMount option enabled. The CSIDriver object is used by Kubelet and applies certain SElinux settings to mounted volumes.

But yes, I do not think .Values.CSIDriver.seLinuxMount is used anywhere 🤔 Maybe @Rakshith-R remembers/knows what the intention was.

@Rakshith-R
Copy link
Contributor

Choose a reason for hiding this comment

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

When .Values.selinuxMount is enabled, it makes sense that the CSIDriver should also have its seLinuxMount option enabled. The CSIDriver object is used by Kubelet and applies certain SElinux settings to mounted volumes.

.Values.selinuxMount is for mounting the host /etc/selinux inside pods to support selinux-enabled filesystems.

.Values.csiDriver.selinuxMount should be used to set csidriver parameter.

But yes, I do not think .Values.CSIDriver.seLinuxMount is used anywhere 🤔 Maybe @Rakshith-R remembers/knows what the intention was.

#4519 raised by @iPraveenParihar fixes this issue.
He has explained it in the pr too.

Thanks for pointing it out @Velociraptor85 !

Please sign in to comment.