<p>I am trying to read a file from server in spark cluster mode using kubernetes, so i put my file on all workers and i mount driver volume using<br>
val conf = new SparkConf().setAppName("sparksetuptest")
.set("spark.kubernetes.driver.volumes.hostPath.host.mount.path", "/file-directory")</p>

<p>Everything works fine here but when i execute it shows that file not found at specific location.
So i mount directory to executor with .set("spark.kubernetes.executor.volumes.hostPath.host.mount.path", "/file-directory")
But now i am not able to execute program it stuck in a never ending process while fetching data.</p>

<p>Please suggest something, so that i can mount my directory with executor and read that file.</p>

harshit saxena
<p>this is an example from <a href="https://github.com/apache/spark/blob/master/docs/running-on-kubernetes.md" rel="nofollow noreferrer">nfs-example</a></p>
<pre><code>spark.kubernetes.driver.volumes.nfs.images.options.server=example.com
spark.kubernetes.driver.volumes.nfs.images.options.path=/data
</code></pre>
<p>I think you need to declare the path that you want to mount under <code>options.path</code> and the <code>spark.kubernetes.driver.volumes.[VolumeType].[VolumeName].mount.path</code> is the mount path in your container</p>
<p>For example:</p>
<p>If I want to mount <code>/home/lemon/data</code> on the node of k8s to the path <code>/data</code> the docker container with VolumeName <code>exepv</code>, then</p>
<pre class="lang-py prettyprint-override"><code>conf.set(&quot;spark.kubernetes.executor.volumes.hostPath.exepv.mount.path&quot;,&quot;/data&quot;)
conf.set(&quot;spark.kubernetes.executor.volumes.hostPath.exepv.options.path&quot;, &quot;/home/lemon/data&quot;)
</code></pre>
<p>after this, you can access the path <code>/data</code> in your executor container</p>
