-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Here is the code:
from kubernetes import config
import kubernetes.client
from kubernetes.client.rest import ApiException
config.load_incluster_config()
api_instance = kubernetes.client.CoreV1Api()
...
.........
Error:
config.load_incluster_config()\n File "local/lib/python2.7/site-packages/kubernetes/config/incluster_config.py",
line 93, in load_incluster_config\n cert_filename=SERVICE_CERT_FILENAME).load_and_set()\n
File "local/lib/python2.7/site-packages/kubernetes/config/incluster_config.py",
line 45, in load_and_set\n
self._load_config()\n
File "local/lib/python2.7/site-packages/kubernetes/config/incluster_config.py",
line 51, in _load_config\n
raise ConfigException("Service host/port is not set.")\n
ConfigException: Service host/port is not set.'
python --version
Python 2.7.6
python Kubernetes client version 4.0.0 is installed
When i try to execute the statements directly inside the POD,
i see that neither the host or port info is missing
in the environment.
python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import os
print os.environ["KUBERNETES_SERVICE_HOST"]
10.3.0.1
print os.environ["KUBERNETES_SERVICE_PORT"]
443
[1]+ Stopped python