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

Please implement fsGroup, to automatically chown subdir contents #350

Open
mossroy opened this issue Aug 27, 2024 · 0 comments
Open

Please implement fsGroup, to automatically chown subdir contents #350

mossroy opened this issue Aug 27, 2024 · 0 comments

Comments

@mossroy
Copy link

mossroy commented Aug 27, 2024

It's a stable feature of kubernetes since 1.23: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#configure-volume-permission-and-ownership-change-policy-for-pods, and very useful, especially when you run containers as non-root.

This feature does not seem to be supported by nfs-subdir-external-provisioner.

Here is a test-case:

  • deploy a pvc and a pod using it (with a fsGroup configured). For example with the manifests below
  • on the NFS server, create a file in the corresponding directory, for example with touch test, see its owner/group with ls -ln test
  • restart the pod
  • check again with ls -ln test if the group has been changed to the one specified in fsGroup (70 in my example below)

Example manifests:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: testcase-fsgroup
spec:
  selector:
    matchLabels:
      app: testcase-fsgroup
  replicas: 1
  template:
    metadata:
      labels:
        app: testcase-fsgroup
    spec:
      securityContext:
        fsGroup: 70
        fsGroupChangePolicy: "Always"
      containers:
      - image: nginx:latest
        name: nginx
        volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: testcase-fsgroup
      volumes:
      - name: testcase-fsgroup
        persistentVolumeClaim:
          claimName: testcase-fsgroup
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: testcase-fsgroup
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: nfs-client
  resources:
    requests:
      storage: 10Mi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant