1

I'm running the theia code-editor on my EKS cluster and the image's default user is theia on which I grant read and write permissions on /home/project. However, when I mount that volume /home/project on my EFS and try to read or write on /home/project it returns permission denied I tried using initContainer but still the same problem:

apiVersion: apps/v1
kind: Deployment
metadata:
   name: atouati
spec:
  replicas: 1
  selector:
    matchLabels:
      app: atouati
  template:
    metadata:
      labels:
        app: atouati
    spec:
      initContainers:
      - name: take-data-dir-ownership
        image: alpine:3
        command:
        - chown
        - -R
        - 1001:1001
        - /home/project:cached
        volumeMounts:
        - name: project-volume
          mountPath: /home/project:cached
      containers:
      - name: theia
        image: 'xxxxxxx.dkr.ecr.eu-west-1.amazonaws.com/theia-code-editor:latest'
        ports:
        - containerPort: 3000
        volumeMounts:
        - name: project-volume
          mountPath: "/home/project:cached"   
      volumes:
      - name: project-volume
        persistentVolumeClaim:
          claimName: local-storage-pvc

---

apiVersion: v1
kind: Service
metadata:
  name: atouati
spec:
  type: ClusterIP
  selector:
    app: atouati
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000

When I do ls -l on /home/project

drwxr-xr-x 2 theia theia  6 Aug 21 17:33 project

On the efs directory :

drwxr-xr-x 4 root root 6144 Aug 21 17:32 
Rico
  • 58,485
  • 12
  • 111
  • 141
touati ahmed
  • 311
  • 8
  • 21

1 Answers1

2

You can instead set the securityContext in your pod spec to run the Pods as uid/gid 1001.

For example

apiVersion: apps/v1
kind: Deployment
metadata:
   name: atouati
spec:
  replicas: 1
  selector:
    matchLabels:
      app: atouati
  template:
    metadata:
      labels:
        app: atouati
    spec:
      securityContext:
        runAsUser: 1001
        runAsGroup: 1001
        fsGroup: 1001
      containers:
      - name: theia
        image: 'xxxxxxx.dkr.ecr.eu-west-1.amazonaws.com/theia-code-editor:latest'
        ports:
        - containerPort: 3000
        volumeMounts:
        - name: project-volume
          mountPath: "/home/project:cached"   
      volumes:
      - name: project-volume
        persistentVolumeClaim:
          claimName: local-storage-pvc

Have you kubectl execd into the container to confirm that that's the uid/gid that you need to use based on the apparent ownership?

OregonTrail
  • 8,594
  • 7
  • 43
  • 58