Set volume mount user group and file permissions in kubernetes

0 votes

I'm using kops to run my kubernetes cluster. I'm trying to use an EBS volume with a container which is visible from my app by it shows it as read only because my app is not running as root. I want to use the PVC as a user other than root. I cannot find any control  by which I can change the user or group or file permissions for the mounted path.

My deployment YAML:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: notebook-1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: notebook-1
    spec:
      volumes:
      - name: notebook-1
        persistentVolumeClaim:
          claimName: notebook-1
      containers:
      - name: notebook-1
        image: jupyter/base-notebook
        ports:
        - containerPort: 8888
        volumeMounts:
        - mountPath: "/home/jovyan/work"
          name: notebook-1
Jan 16 in Kubernetes by Damon Salvatore
• 5,510 points
1,818 views

1 answer to this question.

0 votes

There's a setting in Pod Security Context called fsGroup. This will allow you to set the group ID that has the volume. example:

apiVersion: v1
kind: Pod
metadata:
  name: hello-world
spec:
  containers:
  # specification of the pod's containers
  # ...
  securityContext:
    fsGroup: 1234

More info: https://kubernetes.io/docs/concepts/policy/security-context/

answered Jan 16 by ajs3033
• 7,280 points

Related Questions In Kubernetes

0 votes
1 answer
0 votes
3 answers

Using multiple commands in a kubernetes yaml file

Try something like this: containers: - name: ...READ MORE

answered Apr 23 in Kubernetes by lyza
4,787 views
0 votes
1 answer

ConfigMaps volume not creating file in container

Did a little research and found the ...READ MORE

answered Sep 6, 2018 in Kubernetes by Atul
• 10,240 points
54 views
0 votes
1 answer

What is unknown user client in kubernetes?

I think your Legacy Authorisation has been ...READ MORE

answered Sep 12, 2018 in Kubernetes by DareDev
• 6,810 points
48 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
2,096 views
+3 votes
1 answer
0 votes
1 answer

Kubernetes: Insufficient CPU's and MatchNodeSelector in Openshift.

That error message does not mean that ...READ MORE

answered Sep 7, 2018 in Kubernetes by ajs3033
• 7,280 points
312 views
0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,280 points
319 views