I have a test Kubernetes cluster (Minikube) running in a Docker container.
I want to write some Python code to start jobs on that cluster. If I go inside the container:
$ docker exec -it kubernetes /bin/sh
#/ apk add python3
#/ apk add py3-pip
#/ pip install kubernertes
#/ pyhton3
>>> from kubernetes import config, client
>>> config.load_kube_config()
It works, and I can then create a client and do my stuff.
However, if I run the same Python commands from the host machine:
>>> config.load_kube_config()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/python/kubernetes/config/kube_config.py", line 814, in load_kube_config
loader = _get_kube_config_loader(
File "/path/to/python/kubernetes/config/kube_config.py", line 773, in _get_kube_config_loader
raise ConfigException(
kubernetes.config.config_exception.ConfigException: Invalid kube-config file. No configuration found.
That sort of makes sense, since kubernetes is not running on the machine. How do I go around this ? Is there another way to fetch the config file ?