Kubernetes - setting custom permissions/file ownership per volume (and not per pod)

后端 未结 2 793
遥遥无期
遥遥无期 2021-01-13 10:18

Is there any way to set per-volume permissions/ownership in Kubernetes declaratively?

Usecase:

  • a pod is composed of two containers, running as two dist
相关标签:
2条回答
  • 2021-01-13 10:30

    One solution is to use init-container to change permissions of mounted directories.

    The init-container would need to mount both volumes (from both containers), and do the needed chown/chmod operations.

    Drawbacks:

    • extra container that needs to be aware of other containers' specific (ie. uid/gid)
    • init container needs to run as root to perform chown
    0 讨论(0)
  • 2021-01-13 10:43

    It can be done with adding one init container with root access.

        initContainers:
        - name: changeowner
          image: busybox
          command: ["sh", "-c", "chown -R 200:200 /<volume>"]   
          volumeMounts:
          - name: <your volume>
            mountPath: /<volume>
    
    0 讨论(0)
提交回复
热议问题