I am thinking of creating a setup where every directory inside main directory is mounted onto a different disk.
So basically volume config would mean I have 3 different volumes attached to 3 different persistent storage disks:
volumes:
- name: demo-pdf
persistentVolumeClaim:
claimName: demo-pdf
- name: demo-tsv
persistentVolumeClaim:
claimName: demo-tsv
- name: demo-csv
persistentVolumeClaim:
claimName: demo-csv
And then for volume mounts:
volumeMounts:
- name: demo-pdf
mountPath: "/code/p_data/pdf"
subPath: pdf
- name: demo-tsv
mountPath: "/code/p_data/tsv"
subPath: tsv
- name: demo-csv
mountPath: "/code/p_data/csv"
subPath: csv
But the app would still treat everything in the main p_data
folder as single storage accesible by the app.
Is this setup achievable in Kubernetes and are there any significant drawbacks to this?
As per the official documentation
A process in a container sees a filesystem view composed from the initial contents of the container image, plus volumes (if defined) mounted inside the container. The process sees a root filesystem that initially matches the contents of the container image. Any writes within that filesystem hierarchy, if allowed, affect what that process views when it performs a subsequent filesystem access.
Since you are trying to mount three different volumes you just need to use a normal volume mount and mount these volumes in the exact path, subPath is used when you are trying to use a single volume for multiple subdirectories.
Try removing the subPath in your manifest file as given below
volumeMounts:
- name: demo-pdf
mountPath: "/code/p_data/pdf"
- name: demo-tsv
mountPath: "/code/p_data/tsv"
- name: demo-csv
mountPath: "/code/p_data/csv"