I have a k8s YAML file with 2 containers. initContainer
and the main container. I am using a volume to mount a script file to be run in initContainer
but I am getting permission denied
error. Here is the snippet.
volumes:
- name: casacm-script
configMap:
name: {{ include "oxauth.name" . }}-casacm-script
and in initContainer
I mount it like
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
Change your volumes to below to add permission.
volumes:
- name: casacm-script
configMap:
name: {{ include "oxauth.name" . }}-casacm-script
defaultMode: 0777