<p>I have a k8s YAML file with 2 containers. <code>initContainer</code> and the main container. I am using a volume to mount a script file to be run in <code>initContainer</code> but I am getting <code>permission denied</code> error. 
Here is the snippet.</p>

<pre><code>  volumes:
  - name: casacm-script
    configMap:
      name: {{ include "oxauth.name" . }}-casacm-script 
</code></pre>

<p>and in <code>initContainer</code> I mount it like</p>

<pre><code> initContainers:
  - name: {{ include "oxauth.name" .}}-init 
    image: gcr.io/cloud-builders/kubectl:latest
    command: 
      - sh
      - -c 
      - /scripts/casacm.sh   
    volumeMounts:
      - name: casacm-script
        mountPath: "/scripts/casacm.sh"
        subPath: casacm.sh
</code></pre>

<p>Change your volumes to below to add permission. </p>

<pre><code>volumes:
  - name: casacm-script
    configMap:
      name: {{ include "oxauth.name" . }}-casacm-script 
      defaultMode: 0777
</code></pre>
