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:
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,