<p>I'm running a Python script as a Kubernetes job. But I'm having the next issue. I've already tried with <code>chmod -R 777 /home/vagrant/</code> but it doesn't make the script run successfully.</p>

<pre><code>Traceback (most recent call last):
  File "app.py", line 39, in &lt;module&gt;
    main()
  File "app.py", line 28, in main
    config.load_kube_config(config_file=kubeconfig)
  File "/usr/local/lib/python3.6/site-packages/kubernetes/config/kube_config.py", line 470, in load_kube_config
    config_persister=config_persister)
  File "/usr/local/lib/python3.6/site-packages/kubernetes/config/kube_config.py", line 427, in _get_kube_config_loader_for_yaml_file
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/vagrant/.kube/config'
</code></pre>

<p>As you can see the script fails supousedly because such file doesn't exists, but when I do an <code>ls</code> the file shows that it does exists.</p>

<pre><code>vagrant@vagrant:/vagrant/podsLister$ kubectl delete job pod-lister
job.batch "pod-lister" deleted
vagrant@vagrant:/vagrant/podsLister$ ls /home/vagrant/.kube/
cache  config  http-cache
</code></pre>

Mariano Rodríguez
<p>The problem is that the script is running inside a Docker container. That container has its own filesystem, not the filesystem of whatever machine happens to be hosting it. That is, in fact, most of the <em>point</em> of containers: they act like an isolated, separate computer, without you needing an <em>actual</em> separate computer.</p>

<p>The solution is a little less obvious, because it's not clear why you expected this to work, or what you're trying to do. Things that might make sense include:</p>

<ul>
<li>Changing your docker build script to copy the file into the container.</li>
<li>Setting up host file sharing, so part of the real machine's filesystem is available to containers, then making the container mount that.</li>
<li>Setting up "normal" file sharing, so part of the real machine's filesystem is available to anyone on the network, then making the container mount that.</li>
<li>Using some higher-level feature like Kubernetes ConfigMaps to expose the file to containers.</li>
</ul>
