How to solve error `No such file or directory` in a container that is volume mounted

7/15/2019

I have 2 helm manifests - Jobs. One is supposed to create/generate a file with some configurations. The other is supposed to consume/use the generated file. generate works fine. But the other one -load - can't access the config file. Getting an error No such file or directory

Provided below are code snippets for the volumes. I think something is not right. I am using StorageClass object.

Thank you all

generate.yml

volumes:
        - name: {{ template "gluu.fullname" . }}-config
          persistentVolumeClaim: 
            claimName: {{ template "gluu.fullname" . }}-config-volume-claim
      containers:
        - name: {{ template "gluu.fullname" . }}-config-init
          image: gluufederation/config-init:3.1.6_02
          volumeMounts:
            - mountPath: /opt/config-init/db/
              name: {{ template "gluu.fullname" . }}-config
              subPath: db

load.yml

volumes:
        - name: {{ template "gluu.fullname" . }}-config
          persistentVolumeClaim:
            claimName: {{ template "gluu.fullname" . }}-config-volume-claim
      containers:
        - name: {{ template "gluu.fullname" . }}-config-init-load
          image: gluufederation/config-init:3.1.6_03
          volumeMounts:
            - mountPath: /opt/config-init/db
              name: {{ template "gluu.fullname" . }}-config
              subPath: db
-- Shammir
devops
kubernetes
kubernetes-helm
minikube

1 Answer

7/16/2019

Could be your Volume can't be mounted read-write by more than one pod. Try to mount the volume in the second pod

volumeMounts:

    readOnly: true

by default is readOnly: false

-- EAT
Source: StackOverflow