<p>I am getting an error mounting a config file, can anyone assist?</p>

<p>With subPath on volumeMounts I get the error:</p>

<pre><code>Error: stat /var/config/openhim-console.json: no such file or directory.
</code></pre>

<p>I can read this file.</p>

<p>Without subPath on volumeMounts I get this error:</p>

<pre><code>Warning  Failed   13s                kubelet, ip-10-0-65-230.eu-central-1.compute.internal  Error: failed to start container "openhim-console": Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"rootfs_linux.go:57: mounting \\\"/var/config/openhim-console.json\\\" to rootfs \\\"/var/lib/docker/overlay2/7408e2aa7e93b3c42ca4c2320681f61ae4bd4b02208364eee8da5f51d587ed21/merged\\\" at \\\"/var/lib/docker/overlay2/7408e2aa7e93b3c42ca4c2320681f61ae4bd4b02208364eee8da5f51d587ed21/merged/usr/share/nginx/html/config/default.json\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
  Warning  BackOff  2s  kubelet, ip-10-0-65-230.eu-central-1.compute.internal  Back-off restarting failed container
</code></pre>

<p>Here is the deployment.yaml</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: openhim-console-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: openhim-console
  template:
    metadata:
      labels:
        component: openhim-console
    spec:
      volumes:
        - name: console-config
          hostPath:
            path: /var/config/openhim-console.json
      containers:
        - name: openhim-console
          image: jembi/openhim-console:1.13.rc
          ports:
            - containerPort: 80
          volumeMounts:
            - name: console-config
              mountPath: /usr/share/nginx/html/config/default.json
              subPath: default.json
          env:
            - name: NODE_ENV
              value: development
</code></pre>

Anton Swanevelder
<p>Probably <code>hostPath</code> should hold a <code>path</code> rather than your file path: <code>/var/config/openhim-console.json</code> as you're mounting a volume, not a file. </p>

<p>If you are, the <code>type</code> should be specified as <code>File</code>.</p>

<p>See also <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">docs#hostpath</a></p>
