k8s Deployment EFS VolumeMount is mounted as only root:root owner, How can I specipy specific user?

2/4/2021

My Deployment VolumeMount Config. jane-vol means EFS volume

 volumeMounts:
        - name: jane-vol
          mountPath: /mnt/utils
          subPath: utils

In my pod, I can see the volume mounted as a root

$cd /mnt/
$ll
drwxr-xr-x 2 root   root   6144  24 19:42 utils

However, I want to change the root:root -> jane:jane.

How can I do this only in Deployment.

Is there a way to handle this only on Deployment?

I would appreciate if someone could give me some advice.

-- sun lim
kubernetes

1 Answer

2/4/2021

A good practice, to avoid modifying the docker image just for this use case, would be to add an initContainer that modifies the volume mount user permissions:

https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/

-- paltaa
Source: StackOverflow