<p>Currently I try to setup a Nextcloud on Azure Kubernetes Service as an exercise. Basically the application seems running, but after connecting the Database, Nextcloud ending with something like...</p>
<blockquote>
<p>Please change the permissions of your storage to 0770 to prevent other people from accessing your data</p>
</blockquote>
<p>I guess cause I used a <code>azurefile</code> share as persistent volume. My pvc deployment looks like this:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nextcloud-shared-storage-claim
  labels: 
    app: nextcloud
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: azurefile
  resources:
    requests:
      storage: 5Gi
</code></pre>
<p>I've already researched on that topic and find ways to realize the use of permissions for pods with <code>securityContext</code>. Because I've only just started with Kubernetes on Azure I struggle a bit on binding my Deployment file for nextcloud with a pod, that applies the permissions.</p>
<p><em>To complete the post - here is the deployment file for the Nextcloud I used</em></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nextcloud-server
  labels:
    app: nextcloud
spec:
  replicas: 1
  selector:
    matchLabels:
      pod-label: nextcloud-server-pod
  template:
    metadata:
      labels:
        pod-label: nextcloud-server-pod
    spec:
      containers:
      - name: nextcloud
        image: nextcloud:20-apache
        volumeMounts:
        - name: server-storage
          mountPath: /var/www/html
          subPath: server-data
      volumes:
      - name: server-storage
        persistentVolumeClaim:
          claimName: nextcloud-shared-storage-claim
---
apiVersion: v1
kind: Service
metadata:
  name: nextcloud-server
  labels:
    app: nextcloud
spec:
  selector:
    pod-label: nextcloud-server-pod
  ports:
  - protocol: TCP
    port: 80
</code></pre>
<p>I guess/hope that it's totally simple.</p>

<p>Posting this answer as community wiki since it might be helpful for the community. Feel free to expand.</p>
<p>As mentioned by @Nick Graham in the comments</p>
<blockquote>
<p>To modify the permissions on a mounted volume you’ll need to execute a script after the container starts up. Some images give you the option to copy scripts into a particular folder that are then executed at start up, check the docs to see if the image your using provides that functionality</p>
</blockquote>
<p>There are few <a href="https://stackoverflow.com/questions/43544370">examples</a>.</p>
<hr />
<p>Additionally according to this <a href="https://github.com/Azure/AKS/issues/225#issuecomment-371007021" rel="nofollow noreferrer">comment</a> you can try to specify this permissions in your storage class.</p>
