Permission denied when chown on elasticsearch data directory in kubernetes statefulset Permission denied when chown on elasticsearch data directory in kubernetes statefulset kubernetes kubernetes

Permission denied when chown on elasticsearch data directory in kubernetes statefulset


This particular docker image expects the data directory to be writable by uid 2000. You can tell Kubernetes to chown (sort of) the mount point for your pod by adding .spec.securityContext.fsGroup:

apiVersion: apps/v1beta1kind: StatefulSetmetadata:  name: esnodespec:  ...  securityContext:    fsGroup: 2000

(end of course you can get rid of the chown hack or the initContainer)

fsGroup: integer: A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership 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'd with rw-rw---- If unset, the Kubelet will not modify the ownership and permissions of any volume.