<p>I am trying to mount a config file created as a secret to a specific path in a pod. However, the mount path on the pod is always generated as a directory.  Could someone tell me what am I doing wrong? </p>

<pre><code>&gt; kubectl get secrets config
NAME      TYPE      DATA      AGE
config    Opaque    1         29m
</code></pre>

<p>pod yaml: </p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-pd-plus-secret
spec:
  containers:
  - image: ubuntu
    name: bash
    stdin: true
    tty: true
    volumeMounts:
      - name: "config"
        mountPath: "/mnt/configFile"
        subPath: "configFile"
  volumes:
  - name: "config"
    secret:
      secretName: "config"
</code></pre>

<p>After the pod is created, I try to read the file on the pod, and get: </p>

<pre><code>cat: /mnt/configFile: Is a directory
</code></pre>

<p>I am using: kubernetes client version 1.9.0 and server version 1.8.6</p>

<p>The syntax you want is to select just the secret's <code>items:</code>, and not try to use <code>subPath</code> in that manner. It's <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#secretvolumesource-v1-core" rel="nofollow noreferrer">documented in <code>SecretVolumeSource</code></a></p>

<pre><code>  volumes:
  - name: config
    secret:
      secretName: config
      items:
      - key: configFile
        path: configFile
</code></pre>
