I have a minikube cluster with a grafana pod running in it.

I have mounted a directory for grafana to use as a persistant volume to store. minikube mount /var/tmp/minikube-folder1:/folder1

I receive the output

📁  Mounting host path /var/tmp/minikube-folder1 into VM as /folder1 ...
    ▪ Mount type:   9p
    ▪ User ID:      docker
    ▪ Group ID:     docker
    ▪ Version:      9p2000.L
    ▪ Message Size: 262144
    ▪ Options:      map[]
    ▪ Bind Address:
🚀  Userspace file server: ufs starting
✅  Successfully mounted /var/tmp/minikube-folder1 to /folder1

i bind to the folder as such in my grafana yaml

apiVersion: v1
kind: PersistentVolumeClaim
  name: pvc-grafana
  volumeName: grafana-pv
    - ReadWriteMany
      storage: 1Gi
apiVersion: v1
kind: PersistentVolume
  name: grafana-pv
  storageClassName: standard
    - ReadWriteMany
    storage: 2Gi
    path: /folder1

and eventually mount it on my container as such

   [spec..tempalate..spec above]

      - name: mygrafana
        image: grafana/grafana
          - containerPort: 3000 
          - name: grafana-storage
            mountPath: /var/lib/grafana

       - name: grafana-storage
            claimName: pvc-grafana

my grafana pod cant launch and always complains the permissions arent correct on /var/lib/grafana

I can remedy it by manually going into /var/tmp/minikube-folder1/ and chmod 777ing the folders each time a new one appears (ex /var/lib/grafana/alerting), but this seems like an inefficient and wrong strategy.

Is there someway to not have the minikube setup have these filesystem permission conflicts?

1 Answer 1


You have multiples solutions

1 - Set a uid and gid when creating the mount

This imply knowing the uid and gid of the user running inside your pod. To get it you could do something like this :

$ kubectl run -ti debug --image grafana/grafana --command bash
If you don't see a command prompt, try pressing enter.
debug:/usr/share/grafana$ id
uid=472(grafana) gid=0(root) groups=0(root)

Then when creating the mount with minikube, set the uid and gid

$ minikube mount /var/tmp/minikube-folder1:/folder1 --uid 472 --gid 0

Now in your pod you can see that the /var/lib/grafana/ permissions are correct

grafana-57d4899dd7-fsp5z:/usr/share/grafana$ id
uid=472(grafana) gid=0(root) groups=0(root),47
grafana-57d4899dd7-fsp5z:/usr/share/grafana$ ls -lnd /var/lib/grafana/
drwxrwxr-x    1 472      0             4096 Aug 11 14:19 /var/lib/grafana/

2 - Use a security context to run the pod

Localy your folder is created with your user, you can tell your pod to use the same uid as your local user.

First you need to get the uid of the user who created /var/tmp/minikube-folder1

$ ls -lnd /var/tmp/minikube-folder1
total 4
drwxrwxr-x 2 1000 1000 4096 août  11 16:06 /var/tmp/minikube-folder1

Let say the uid is 1000.

In your deployment configuration (grafana yaml), you can set the runAsUser directive :

        runAsUser: 1000

Now if you check in your started pod you can see that it's started with uid 1000

$ kc exec -ti grafana-7c895564cc-w26p6 -- bash
grafana-7c895564cc-w26p6:/usr/share/grafana$ id
uid=1000 gid=0(root) groups=0(root),472

And that's the same user as the /var/lib/grafana/ folder in the pod :

grafana-5f75d8ff65-dhbb5:/usr/share/grafana$ ls -lnd /var/lib/grafana/
drwxrwxr-x    1 1000     999           4096 Aug 11 14:16 /var/lib/grafana/

Hope this is clear and that it helps !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.