I'm running a Python script as a Kubernetes job. But I'm having the next issue. I've already tried with chmod -R 777 /home/vagrant/
but it doesn't make the script run successfully.
Traceback (most recent call last):
File "app.py", line 39, in <module>
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'
As you can see the script fails supousedly because such file doesn't exists, but when I do an ls
the file shows that it does exists.
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
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 point of containers: they act like an isolated, separate computer, without you needing an actual separate computer.
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: