【发布时间】:2019-04-18 08:57:20
【问题描述】:
我已经设置了官方 Kubernetes Python 客户端 (https://github.com/kubernetes-client/python)。
我正在运行 Python 代码以连接到 Kubernetes 集群,但它抛出了一个错误:
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='****', port=6443): 最大重试次数超出 url: /api/v1/namespaces/default/pods (由 NewConnectionError(': Failed to建立新连接:[Errno 110] Connection timed out',))
安装要求:
cachetools 3.1.0 ,
certifi 2019.3.9 ,
chardet 3.0.4 ,
google-auth 1.6.3 ,
idna 2.8 ,
ipaddress 1.0.22 ,
kubernetes 10.0.0-snapshot ,
oauthlib 3.0.1 ,
pip 19.0.3 ,
pyasn1 0.4.5 ,
pyasn1-modules 0.2.4 ,
python-dateutil 2.8.0 ,
PyYAML 5.1 ,
requests 2.21.0 ,
requests-oauthlib 1.2.0 ,
rsa 4.0 ,
setuptools 41.0.0 ,
six 1.12.0 ,
urllib3 1.24.1 ,
websocket-client 0.56.0 ,
wheel 0.33.1
kubectl 在相同的配置 $HOME/.kube/config 和相同的代理设置下工作正常。
下面是我的代码:
from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
【问题讨论】:
-
您是否尝试过从正在执行python的主机执行
kubectl? -
@Crou,是的,kubeclt 在执行 python 代码的同一主机上运行良好。 kubectl 和 python 执行的代理设置相同。我也试过kubernetes官方golang客户端。它工作正常。我只面临 python 设置的问题。我使用的 python 版本有问题吗?
-
您使用的是哪个版本的 Python 客户端和 Kubernetes?
-
@char Kubernetes 版本:v1.11.8 ----------------------- Kubernetes-Python 客户端版本:10.0.0 $pip show kubernetes 名称:kubernetes 版本:10.0.0-snapshot 摘要:Kubernetes python 客户端-----------
-
也许在 python 客户端 repo 上打开一个问题?
标签: python-3.x kubernetes kubectl kubernetes-python-client