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

feat: Add fsGroup support on CSI driver #20

Merged
merged 3 commits into from
Feb 12, 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
3 changes: 3 additions & 0 deletions deploy/helm/csi-wekafsplugin/templates/driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ spec:
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
{{- if semverCompare ">=1.19.0" .Capabilities.KubeVersion.Version }}
fsGroupPolicy: File
{{- end }}
27 changes: 27 additions & 0 deletions examples/fsgroup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Overview
## Example Intentions
1. This example concentrates on setting fsGroup on Weka CSI volume
2. The example makes a use of a directory-backed volume, but the feature is functional on any other type of volume backings

## Weka CSI Plugin Upgrade Implications
Since CSIDriver objects are immutable, adding support for fsGroup requires the plugin to be uninstalled and reinstalled.
> **NOTE:** Existing persistent volumes or workloads using them will not be affected

# Workflow
> All commands below may be executed by `kubectl apply -f <FILE>.yaml`
1. Create storageclass `storageclass-wekafs-snap-api` (Located in [../dynamic_directory/storageclass-wekafs-dir-api.yaml](../dynamic_directory/storageclass-wekafs-dir-api.yaml))
2. Create CSI secret `csi-wekafs-api-secret` (Located in [../common/csi-wekafs-api-secret.yaml](../common/csi-wekafs-api-secret.yaml))
3. Provision a new volume `pvc-wekafs-fsgroup`
4. Create application that writes timestamp every 10 seconds into `/data/temp.txt`: `csi-app-fsgroup` and has different non-root permissions
5. Attach to the application and validate filesystem contents and permissions by issuing
```
kubectl exec csi-app-fsgroup -- ls -al /data
```
The output should resemble this:
```
$ ls -al /data
total 8
drwxrws--- 1 root 2000 0 Feb 12 11:46 .
drwxr-xr-x 1 root root 4096 Feb 12 11:46 ..
-rw-r--r-- 1 2000 2000 2345 Feb 12 11:57 temp.txt
```
25 changes: 25 additions & 0 deletions examples/fsgroup/csi-app-fsgroup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
kind: Pod
apiVersion: v1
metadata:
name: csi-app-fsgroup
spec:
securityContext:
runAsUser: 2000
runAsGroup: 2000
fsGroup: 2000
# make sure that pod is scheduled only on node having weka CSI node running
nodeSelector:
topology.csi.weka.io/global: "true"
containers:
- name: my-frontend
image: ubuntu
volumeMounts:
- mountPath: "/data"
name: my-csi-volume
command: ["/bin/sh"]
args: ["-c", "while true; do echo `date` hello >> /data/temp.txt; sleep 10;done"]
terminationGracePeriodSeconds: 1
volumes:
- name: my-csi-volume
persistentVolumeClaim:
claimName: pvc-wekafs-fsgroup # defined in pvc-wekafs-dir-api.yaml
12 changes: 12 additions & 0 deletions examples/fsgroup/pvc-wekafs-fsgroup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-wekafs-fsgroup
spec:
accessModes:
- ReadWriteMany
storageClassName: storageclass-wekafs-snap-api
volumeMode: Filesystem
resources:
requests:
storage: 1Gi
4 changes: 0 additions & 4 deletions semicolon_delimited_script

This file was deleted.