title: Kubernetes : hostPath storage permissions
body: <p>Problem : Not able to write in the directory inside the container. </p>
  
  <p>I am using hostPath storage for the persistent storage requirements. I am not using PV anc PVC to use hospath, instead of that, using it's volume plugin. for example</p>
  
  <pre><code>{
      "apiVersion": "v1",
      "id": "local-nginx",
      "kind": "Pod",
      "metadata": {
          "name": "local-nginx"
      },
      "spec": {
          "containers": [
               {
                   "name": "local-nginx",
                   "image": "fedora/nginx",
                   "volumeMounts": [
                       {
                           "mountPath": "/usr/share/nginx/html/test",
                           "name": "localvol"
                       }
                   ]
               }
          ],
          "volumes": [
              {
                   "name": "localvol",
                   "hostPath": {
                      "path": "/logs/nginx-logs"
                   }
              }
          ]
      }
  }
  </code></pre>
  
  <p>Note: nginx pod is just for exmaple.</p>
  
  <p>My directory on host is getting created as "drwxr-xr-x. 2 root root 6 Apr 23 18:42 /logs/nginx-logs"
  and same permissions are reflecting inside the pod, but as it's 755, other user i.e. user inside the pod is not able to write/create file inside the mounted dir.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>Is there any way out to avoid the problem specified above?</p></li>
  <li><p>Is there any way to specify the directory permission in case of Hostpath storage?</p></li>
  <li><p>Is there any field which I can set in the following definition to give the required permission?</p></li>
  </ol>
  
  <hr>
  
  <pre><code>"volumes":{
     "name": "vol",
      "hostPath": {
        "path": "/any/path/it/will/be/replaced"}}
  </code></pre>