<p>I am trying to deploy a SparkJava REST app in a Kubernetes container on my Windows machine.</p>
<ul>
<li>Windows 10</li>
<li>Kubernetes v1.22.5</li>
<li>(edit) base image: openjdk:8-alpine</li>
</ul>
<p>I am trying to read in a properties file when the app starts.  I have created a volume mount in my YAML that points to where the file is.  However, the container always crashes when I start it. I have taken screenshots of the YAML and the logs from the container. I have tried logging some test results to make sure the system can find the mounted drive and the file, and I also logged the <code>canRead</code> property to debug whether it is a permissions problem.  Tests seem to indicate the file is visible and readable; but the error that is thrown would indicate otherwise.</p>
<p>Some research I did points to a possible bug or hack required to get the volume mount working correctly, but I haven't read anything that seems to mirror my issue closely.</p>
<p>Does anybody see what I am doing wrong?</p>
<p><a href="https://i.stack.imgur.com/hAkm7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hAkm7.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/DToG5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DToG5.png" alt="enter image description here" /></a></p>
<p>Here is my java:</p>
<pre><code>import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import static spark.Spark.*;

public class RestClient {

    private static final int sparkPort = 4567;

    public static void main(String[] args) {
        port(sparkPort);

        String hostPath = &quot;/root&quot;;
        String propsFilePath = hostPath + &quot;/resttest.properties&quot;;

        File host = new File(hostPath);

        if(!host.exists()){
            System.out.println(&quot;Could not find host path&quot;);
            return;
        }

        System.out.println(&quot;Found host path&quot;);

        File propsFile = new File(propsFilePath);

        if(!propsFile.exists()){
            System.out.println(&quot;Could not find host path&quot;);
            return;
        }

        System.out.println(&quot;Found propsFile path&quot;);
        System.out.println(&quot;&gt;&gt; isDirectory: &quot; + propsFile.isDirectory());
        System.out.println(&quot;&gt;&gt; isFile: &quot; + propsFile.isFile());
        System.out.println(&quot;&gt;&gt; canRead: &quot; + propsFile.canRead());


        Properties properties = new Properties();
        FileInputStream fileInputStream = null;

        try {
            fileInputStream = new FileInputStream(propsFile);
        } catch (SecurityException fnf) {
            System.out.println(&quot;Security issue&quot;);
            fnf.printStackTrace();
            return;
        } catch (FileNotFoundException fnf) {
            System.out.println(&quot;Could not open file&quot;);
            fnf.printStackTrace();
            return;
        }

        try {
            properties.load(fileInputStream);
        } catch (IOException fe1) {
            fe1.printStackTrace();
        }

        get(&quot;/hello&quot;, (req,res) -&gt; {
            return &quot;Hello World!  My properties file is &quot;+ propsFile +&quot; and from it I learned I was &quot;+ properties.getProperty(&quot;age&quot;) +&quot; years old&quot;;
        });
    }
}
</code></pre>

RobbieS
<p>Posted community wiki answer based on the <a href="https://github.com/kubernetes/kubernetes/issues/59876" rel="nofollow noreferrer">topic with similar issue on the GitHub</a>. Feel free to expand it.</p>
<hr />
<p>The solution is to add <code>/run/desktop/mnt/host</code> before the <code>/c/users/&lt;some-folder&gt;/&lt;some-folder&gt;/gits/resttest</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>- name: approot
  hostPath:
    path: /run/desktop/mnt/host/c/users/&lt;some-folder&gt;/&lt;some-folder&gt;/gits/resttest
    type: Directory
</code></pre>
