Skip to content

sourceMountPath or subPath(Expr) for volumes #7

@antoinetran

Description

@antoinetran

Hi,

I have an issue to integrate moosefs-csi in StatefulSet. I need a way to determine the source path to mount. I already know I can make a subPath under volumeMounts such as:

kind: Pod
apiVersion: v1
metadata:
  name: my-csi-app
spec:
  containers:
    - name: my-frontend
      image: busybox
      volumeMounts:
      - mountPath: "/data"
        name: moosefs-volume
        subPath: subdir  # <--------- here
      command: [ "sleep", "1000000" ]
  volumes:
    - name: moosefs-volume
      persistentVolumeClaim:
        claimName: moosefs-csi-pvc

but I need to do this under Volume:

kind: Pod
apiVersion: v1
metadata:
  name: my-csi-app
spec:
  containers:
    - name: my-frontend
      image: busybox
      volumeMounts:
      - mountPath: "/data"
        name: moosefs-volume
      command: [ "sleep", "1000000" ]
  volumes:
    - name: moosefs-volume
      persistentVolumeClaim:
        claimName: moosefs-csi-pvc
      subPath: subdir # <--------- here

Even if it looks the same, it is fundamentally different. I need to be able to choose which directory in the source I want to mount, with the ability to add a POD_NAME in case of StatefulSet.
My use case is OpenLdap, that has a data persistence in /var/lib/openldap. I cannot mount /var/lib/openldap/$(POD_NAME) or I would need to modify the OpenLdap configuration to refer to a dynamic path.

Eg of what I want for my usecase:

kind: Pod
apiVersion: v1
metadata:
  name: my-csi-app
spec:
  containers:
    - name: my-frontend
      image: busybox
      volumeMounts:
      - mountPath: "/data"
        name: moosefs-volume
      command: [ "sleep", "1000000" ]
      env:
        - name: POD_NAME # <--------- here
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
  volumes:
    - name: moosefs-volume
      persistentVolumeClaim:
        claimName: moosefs-csi-pvc
      subPathExpr: $(POD_NAME) # <--------- here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions