<p>I'm writing a <code>kubectl</code> configuration to start an image and copy a file to the container.
I need the file <code>Config.yaml</code> in the <code>/</code> so <code>/Config.yaml</code> needs to be a valid file.
I need that file in the Pod before it starts, so <code>kubectl cp</code> does not work.
I have the <code>Config2.yaml</code> in my local folder, and I'm starting the pod like:</p>

<pre><code>kubectl apply -f pod.yml
</code></pre>

<p>Here follows my pod.yml file.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
   name: python
spec:
   containers:
   - name: python
     image: mypython
     volumeMounts:
     - name: config
       mountPath: /Config.yaml
   volumes:
   - name: config
     hostPath:
       path: Config2.yaml
       type: File
</code></pre>

<p>If I try to use like this it also fails:</p>

<pre><code>      - name: config-yaml
        mountPath: /
        subPath: Config.yaml
        #readOnly: true
</code></pre>

Rodolfo
<p>If you just need the information contained in the config.yaml to be present in the pod from the time it is created, use a configMap instead. </p>

<p>Create a configMap that contains all the data stored in the config.yaml and mount that into the correct path in the pod. This would not work for read/write, but works wonderfully for read-only data</p>
