<p>When I created grafana pod to use official image and mounted /var/lib/grafana, data is not hidden
I don't know why?
According to what I have been studying if pvc is mounted in /var/lib/grafana directory, every file is hidden and can't access.</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: grafana-statefulset
spec:
  serviceName: grafana-service
  selector:
    matchLabels:
      app: grafana
  replicas: 1
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
        - name: grafana
          image: grafana/grafana:latest
          volumeMounts:
          - mountPath: &quot;/var/lib/grafana&quot;
            name: grafana-var
      securityContext:
        runAsUser: 472
        fsGroup: 472
  volumeClaimTemplates:
    - metadata:
        name: grafana-var
      spec:
        accessModes: [&quot;ReadWriteMany&quot;]
        storageClassName: nks-nas-csi
        resources:
          requests:
            storage: 2Gi
</code></pre>
<pre><code>[dev1-user@master-dev-kube-cluster migration]$ k exec -it grafana-statefulset-0 -- sh
/usr/share/grafana $
/usr/share/grafana $ ls -l /var/lib/grafana/
total 912
drwxr-x---    3 grafana  root          4096 Jan  2 08:00 alerting
drwx------    2 grafana  root          4096 Jan  2 08:00 csv
drwxr-x---    2 grafana  root          4096 Jan  2 08:00 file-collections
-rw-r-----    1 grafana  root        909312 Jan  3 01:20 grafana.db
drwxr-xr-x    2 grafana  root          4096 Jan  2 08:00 plugins
drwx------    2 grafana  root          4096 Jan  2 08:00 png
</code></pre>
<p>But i can see and access well /var/lib/grafana directory data</p>
<p>However when I created the image separately, the files in the directories I mounted were hidden and inaccessible.</p>
<pre><code>### First Stage
FROM busybox:latest

RUN mkdir /var/aaaa

COPY ./main.go /

RUN mv main.go /var/aaaa
</code></pre>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: busybox
spec:
  serviceName: busybox
  selector:
    matchLabels:
      app: busybox
  replicas: 1
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
        - name: busybox
          image: busy/test:busybox
          imagePullPolicy: &quot;Always&quot;
          command:
          - sleep
          - &quot;86400&quot;
          volumeMounts:
          - mountPath: /var/aaaa
            name: www
  volumeClaimTemplates:
    - metadata:
        name: www
      spec:
        accessModes: [&quot;ReadWriteMany&quot;]
        storageClassName: nks-nas-csi
        resources:
          requests:
            storage: 2Gi
</code></pre>
<pre><code>[dev1-user@master-dev-kube-cluster migration]$ k exec -it busybox-0 -- sh
/ #
/ #
/ # ls -l /var/aaaa/
total 0
/ #
</code></pre>
<p>There are no main.go file in /var/aaaa directory</p>
<p>The point of this article is not statefulset, it's just a question that came up while testing.</p>
<p>How can I keep using every directory data after mount like grafana official image and how grafana do that?</p>

HHJ
<blockquote>
<p>How can I keep using every directory data after mount like grafana official image and how grafana do that?</p>
</blockquote>
<p>The official image only has <code>plugin</code> in <code>/var/lib/grafana</code>. Those additional directories that you saw; will automatically be created by grafana during start-up if not exist.</p>
