Kubernetes changing permissions of mounted volumes Kubernetes changing permissions of mounted volumes kubernetes kubernetes

Kubernetes changing permissions of mounted volumes


This is happening because you have configured your pod with fsGroup. It's specified under the securityContext:

---securityContext:  fsGroup: 100---

Whenever fsGroup field is specified, all processes of the container are also part of the supplementary group ID. The owner for volumes and any files created in that volume will be Group ID.

Here`s how kubernetes API docs explains that:

fsGroup is a special supplemental group that applies to allcontainers in a pod. Some volume types allow the Kubelet to change theownership of that volume to be owned by the pod:

  1. The owning GID will be the FSGroup
  2. The setgid bit is set (new files created in the volume will be owned by FSGroup)
  3. The permission bits are OR'dwith rw-rw---- If unset, the Kubelet will not modify the ownership andpermissions of any volume.