Share s3fs volume in Kubernetes with two containers in a pod with same subpath

11/10/2019

I have a problem mounting sharing one volume with three containers in a pod and I would like to know how to solve it.

I have a daemonset with 3 containers in a pod:

  • s3fs: This container mounts a s3 bucket as fs in a empty volume
  • myapp: This container needs to mount the volume subpath "/books" in "/books"
  • myapp2: This containers needs to mount the volume subpath "/books/name1" in "/name1" and the volume subpath "/books/name2" in "/name2".

I think the problem can be in how I manage the subpaths in myapp1 and myapp2.

This is the yaml of the daemonset:

      volumes:
      - name: myapp-data
        emptyDir: {}

      containers:
      - name: s3fs
        volumeMounts:
        - name: myapp-data
          mountPath: "/data/s3"
          mountPropagation: Bidirectional
        securityContext:
          capabilities:
            add:
            - SYS_ADMIN
          privileged: true

      - name: myapp1
        volumeMounts:
        - name: myapp-data
          mountPath: "/books"
          subPath: "/books"
          mountPropagation: HostToContainer
        securityContext:
          capabilities:
            add:
            - SYS_ADMIN
          privileged: true

      - name: myapp2
        volumeMounts:
        - name: myapp-data
          mountPath: "/name1"
          subPath: books/name1
          mountPropagation: HostToContainer
        - name: myapp-data
          mountPath: "/name2"
          subPath: books/name2
          mountPropagation: HostToContainer
        securityContext:
          capabilities:
            add:
            - SYS_ADMIN
          privileged: true

With this yaml, the sharing only works with myapp1, but not with myapp2. However If I remove myapp1 from the yaml, myapp2 shares the volume properly.

Any help is appreciated. Thanks,

-- Isaac Morcillo
kubernetes
s3fs
sharing
volume

0 Answers