<p>i'm using azure files as a volume for kubernetes, but i'm facing a problem with it.</p>

<p>i'm able to set permissions on the whole share but i can’t change permissions on a specific file/directory.</p>

<p>If i set the default permissions to the whole share (example 644 (rw/r/r)) and try to change this permissions on specific file (example Chmod 0644 file) chmod doesn’t take any effect it always the default permissions.</p>

<p>Even if i didn’t mention the default permission it will take 0777 and yet i can’t change permissions of file/directory inside the share.</p>

<p>i’ve done some research and i found that this feature is not yet implemented the source is from 2016 I hope this feature is enabled now?</p>

<p>Otherwise is there any other solution to propose ?</p>

<p>Regards,</p>

<hr>

<h1>Update</h1>

<p>Many thanks <strong>@Charles Xu</strong> for your suggestion it's very useful. I used your preposition  but let me explain my use case a little bit:</p>

<ul>
<li>I need to have different files permissions on the same directory because this directory is for SSH. I could change the permission of the folder <strong>.ssh</strong> so all the files inside it have 0644 but as u know i have to change the permission of the private key to 0600</li>
<li><p>It’s mandatory to change the permission on the private key otherwise SSH will not work.</p>

<p>-rw-r--r-- 1 userx userx  182 Oct  8 15:13 config</p>

<p><strong>-rw-r--r--</strong> 1 userx userx 1675 Oct  8 15:13 id_rsa</p>

<p>-rw-r--r-- 1 userx userx  409 Oct  8 15:13 id_rsa.pub</p></li>
</ul>

hajji_0081
<p>First of all, you only can control the permission of the whole Azure file share when you mount it as the persistent volume on the pods. It does not support to change the permission of a special file inside the share.</p>

<p>What I recommend is that you can filter the files into the different directories and the files in the same directory have the same permission. Then you can mount the directories of the Azure file share as the different persistent volumes to the pods and set the persistent volumes with different permissions as you need.</p>

<p>For example, you need a directory with permission 0644 and the files in it with permission 0664. Then you can create a persistent volume like this:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: azurefile
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile
  azureFile:
    secretName: azure-secret
    shareName: aksshare/subfolder1
    readOnly: false
  mountOptions:
  - dir_mode=0644
  - file_mode=0664
  - uid=1000
  - gid=1000
  - mfsymlinks
  - nobrl
</code></pre>

<p>And create a PersistentVolumeClaim which will use the PersistentVolume that you created above:</p>

<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azurefile
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile
  resources:
    requests:
      storage: 5Gi
</code></pre>

<p>Finally, create the pod using the PersistentVolumeClaim with the <code>volumes</code> like this:</p>

<pre><code>...
  volumes:
  - name: azure
    persistentVolumeClaim:
      claimName: azurefile
</code></pre>

<p>When it's OK, you can see things like you set below:</p>

<p><a href="https://i.stack.imgur.com/lLGeL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lLGeL.png" alt="enter image description here"></a></p>
