add support for persistence.subPath option #263

Merged
aleksey.sergey merged 1 commits from add-persistence-subPath into master 2021-12-20 11:58:45 +00:00
aleksey.sergey commented 2021-12-19 21:59:00 +00:00 (Migrated from gitea.com)

Hello,

PR adds a persistence.subPath option to provide user more flexibility on mounting the data PV.
https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath

The setting is similar to e.g. primary.persistence.subPath in MariaDB helm chart:
https://github.com/bitnami/charts/tree/master/bitnami/mariadb

Hello, PR adds a `persistence.subPath` option to provide user more flexibility on mounting the `data` PV. https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath The setting is similar to e.g. `primary.persistence.subPath` in MariaDB helm chart: https://github.com/bitnami/charts/tree/master/bitnami/mariadb
justusbunsi commented 2021-12-19 22:43:01 +00:00 (Migrated from gitea.com)

Hi. Depending on the subpath, it won't work as expected. For some paths, permissions will be changed or it even gets created. For a mount point such things are not allowed. Imaging setting the subpath to git/.ssh, would currently break the init container. I think there is more work to do here.

What was the intention to add the subpath?

Hi. Depending on the subpath, it won't work as expected. For some paths, permissions will be changed or it even gets created. For a mount point such things are not allowed. Imaging setting the subpath to git/.ssh, would currently break the init container. I think there is more work to do here. What was the intention to add the subpath?
aleksey.sergey commented 2021-12-19 23:28:44 +00:00 (Migrated from gitea.com)

Hi!

What was the intention to add the subpath?

In my situation there are multiple PVs pointing into the same NFS share. Different deployments can store their files in different directories by using the subPath option.

Hi! > What was the intention to add the subpath? In my situation there are multiple PVs pointing into the same NFS share. Different deployments can store their files in different directories by using the `subPath` option.
aleksey.sergey commented 2021-12-19 23:38:01 +00:00 (Migrated from gitea.com)

And you are right: if subPath does not exist, k8s will create it asroot and it will likely cause some troubles for the app.

However, PV allocation is a task for k8s cluster admins and if they tell you to use a specific directory then it should be ok to assume that directory is already there and has correct owner/permissions on it.

Also I didn't notice any special handling for subPath in e.g. postgresql or mariadb helm charts. subPath appears in README and under the related volumeMounts. Just as in this PR

And you are right: if `subPath` does not exist, k8s will create it as`root` and it will likely cause some troubles for the app. However, PV allocation is a task for k8s cluster admins and if they tell you to use a specific directory then it should be ok to assume that directory is already there and has correct owner/permissions on it. Also I didn't notice any special handling for `subPath` in e.g. `postgresql` or `mariadb` helm charts. `subPath` appears in README and under the related `volumeMounts`. Just as in this PR
aleksey.sergey commented 2021-12-19 23:54:15 +00:00 (Migrated from gitea.com)

Would also like to mention this one:

Imaging setting the subpath to git/.ssh

What will happen is that PV:/git/.ssh will become POD:/data. We do not alter the mount points inside pod. We only choose a subdirectory in PV to be mounted as /data

Would also like to mention this one: > Imaging setting the subpath to git/.ssh What will happen is that `PV:/git/.ssh` will become `POD:/data`. We do not alter the mount points *inside* pod. We only choose a subdirectory in PV to be mounted as `/data`
justusbunsi commented 2021-12-20 09:44:25 +00:00 (Migrated from gitea.com)

TIL. I read the k8s docs incorrectly or they weren't that detailed when last reading them. You are absolutely right. subpath is for the PV not the Pod mount path.

TIL. I read the k8s docs incorrectly or they weren't that detailed when last reading them. You are absolutely right. subpath is for the PV not the Pod mount path.
justusbunsi (Migrated from gitea.com) approved these changes 2021-12-20 10:11:29 +00:00
justusbunsi (Migrated from gitea.com) left a comment

LGTM

LGTM
luhahn (Migrated from gitea.com) approved these changes 2021-12-20 11:58:38 +00:00
luhahn (Migrated from gitea.com) left a comment

LGTM

LGTM
Sign in to join this conversation.
No description provided.