<p>Installing grafana using helm <a href="https://github.com/grafana/helm-charts" rel="nofollow noreferrer">charts</a>, the deployment goes well and the grafana ui is up, needed to add an existence persistence volume, ran the below cmd:</p>
<pre><code>helm install grafana grafana/grafana -n prometheus --set persistence.enabled=true --set persistence.existingClaim=grafana-pvc
</code></pre>
<p>The init container crashes, with the below logs:</p>
<pre><code>kubectl logs grafana-847b88556f-gjr8b -n prometheus -c init-chown-data                    
chown: /var/lib/grafana: Operation not permitted
chown: /var/lib/grafana: Operation not permitted
</code></pre>
<p>On checking the deployment yaml found this section:</p>
<pre><code>initContainers:
      - command:
        - chown
        - -R
        - 472:472
        - /var/lib/grafana
        image: busybox:1.31.1
        imagePullPolicy: IfNotPresent
        name: init-chown-data
        resources: {}
        securityContext:
          runAsNonRoot: false
          runAsUser: 0
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /var/lib/grafana
          name: storage
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 472
        runAsGroup: 472
        runAsUser: 472
      serviceAccount: grafana
      serviceAccountName: grafana
</code></pre>
<p>Why is the operation failing though its running with <code>runAsUser: 0</code> ? and the pvc is having <code>access:ReadWriteMany</code>, any workaround ? Or am I missing something</p>
<p>Thanks !!</p>

Sanjay M. P.
<p>Actually, sometimes you might want to avoid changing your storage provider settings or it is impossible at all.</p>
<p>In my case, the error described in the question occured while deploying <strong>kube-prometheus-stack</strong> helm chart. I wasn't able to access storage provider settings, so I read through chart's example values, where I noticed following section:</p>
<pre><code>initChownData:
  ## If false, data ownership will not be reset at startup
  ## This allows the prometheus-server to be run with an arbitrary user
  ##
  enabled: true
</code></pre>
<p>I changed <code>enabled</code> to false and after <code>helm upgrade ...</code> pod initialized successfully and with storage working as expected. This appears to be somewhat safer solution than changing storage provider's security policy and certainly requires less effort.</p>
