<p>I set up a local Kubernetes cluster using Kind, and then I run Apache-Airflow on it using Helm.</p>
<p>To actually create the pods and run Airflow, I use the command:</p>
<pre><code>helm upgrade -f k8s/values.yaml airflow bitnami/airflow
</code></pre>
<p>which uses the chart <code>airflow</code> from the <code>bitnami/airflow</code> repo, and &quot;feeds&quot; it with the configuration of <code>values.yaml</code>.
The file <code>values.yaml</code> looks something like:</p>
<pre><code>web:
 extraVolumeMounts:
   - name: functions
     mountPath: /dir/functions/

 extraVolumes:
   - name: functions
     hostPath:
       path: /dir/functions/
       type: Directory
</code></pre>
<p>where <code>web</code> is one component of Airflow (and one of the pods on my setup), and the directory <code>/dir/functions/</code> is successfully mapped from the cluster inside the pod. However, I fail to do the same for a single, specific file, instead of a whole directory.</p>
<p>Does anyone knows the syntax for that? Or have an idea for an alternative way to map the file into the pod (its whole directory is successfully mapped into the cluster)?</p>

localhost
<p>There is a <code>File</code> type for <code>hostPath</code> which should behave like you desire, as it states in the <a href="https://v1-17.docs.kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">docs</a>:</p>
<blockquote>
<p>File: A file must exist at the given path</p>
</blockquote>
<p>which you can then use with the precise file path in <code>mountPath</code>. Example:</p>
<pre><code>web:
 extraVolumeMounts:
   - name: singlefile
     mountPath: /path/to/mount/the/file.txt

 extraVolumes:
   - name: singlefile
     hostPath:
       path: /path/on/the/host/to/the/file.txt
       type: File
</code></pre>
<p>Or if it's not a problem, you could mount the whole directory containing it at the expected path.</p>
<hr />
<p>With this said, I want to point out that using <code>hostPath</code> is (almost always) never a good idea.</p>
<p>If you have a cluster with more than one node, saying that your Pod is mounting an <code>hostPath</code> doesn't restrict it to run on a specific host (even tho you can enforce it with <code>nodeSelectors</code> and so on) which means that if the Pod starts on a different node, it may behave differently, not finding the directory and / or file it was expecting.</p>
<p>But even if you restrict the application to run on a specific node, you need to be ok with the idea that, if such node becomes unavailable, the Pod will not be scheduled on its own somewhere else.. meaning you'll need manual intervention to recover from a single node failure (unless the application is multi-instance and can resist one instance going down)</p>
<hr />
<p>To conclude:</p>
<ul>
<li>if you want to mount a path on a particular host, for whatever reason, I would go for <a href="https://v1-17.docs.kubernetes.io/docs/concepts/storage/volumes/#local" rel="nofollow noreferrer">local</a> volumes.. or at least use hostPath and restrict the Pod to run on the specific node it needs to run on.</li>
<li>if you want to mount small, textual files, you could consider mounting them from <a href="https://kubernetes.io/docs/concepts/configuration/configmap/#using-configmaps-as-files-from-a-pod" rel="nofollow noreferrer">ConfigMaps</a></li>
<li>if you want to configure an application, providing a set of files at a certain path when the app starts, you could go for an init container <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/" rel="nofollow noreferrer">which prepares files for the main container in an emptyDir volume</a></li>
</ul>
