【发布时间】:2021-04-12 22:36:58
【问题描述】:
我在 Minikube VM 内有一个活动的 kubernetes 集群(使用 VirtualBox 作为驱动程序),所以为了部署新容器,我可以下载图像,因为这个连接已经使用 istio 服务布局,现在如果我 ssh 到我的 minikube VM首先,我无法获取 https 内容,但是在设置代理和 no_proxies 之后连接了 http 内容,但是如果我想从容器内部访问任何链接,比如说带有 python 图像和 urllib 库的简单 pod,我想从在这个 pod 中,然后从任何链接(例如 http://python.org)打印内容我无法这样做,我得到的只是没有路由到日志中的主机错误,这表明连接存在一些问题由于代理。
def basic():
import urllib.request
print("inside basic funtion")
with urllib.request.urlopen('http://python.org/') as response:
html = response.read()
print(html)
这是我在容器内作为管道组件运行的 python 代码。
我最近遇到的错误-
Traceback (most recent call last):
File "/usr/local/lib/python3.7/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/local/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/usr/local/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/usr/local/lib/python3.7/http/client.py", line 928, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/local/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "<string>", line 3, in basic
File "/usr/local/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/local/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.7/urllib/request.py", line 1345, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/lib/python3.7/urllib/request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 110] Operation timed out>
我已经启动了 minikube as-
minikube start --cpus 6 --memory 12288 --disk-size=80g --extra-config=apiserver.service-account-issuer=api --extra-config=apiserver.service-account-signing-key-file=/var/lib/minikube/certs/apiserver.key --extra-config=apiserver.service-account-api-audiences=api --kubernetes-version v1.14.0
在设置环境变量之后。
更新: 我创建了一个不同的容器,只是为了从组件内部检查 curl - (我正在使用 kfp 库来创建容器)
def curl_op(text):
return dsl.ContainerOp(
name='curl',
image='tutum/curl',
command=['sh', '-c'],
arguments=['curl -x http://<proxy-server>:<proxy-port> "$0"', text]
)
所以使用上述参数我能够连接到外部链接,这再次确定我需要创建带有代理集的容器。
【问题讨论】:
-
既然您说
http有效但https无效,我认为您已将端口8443添加到k8syml文件中的Service中。另外,请给你发yml文件。 -
是的,我已经检查了这些,不幸的是在我的情况下不是问题,我能够从我的 Minikube VM 内部连接到外部链接,因此可以提取 docker 图像等来创建 pod,问题是当我尝试从 pod 内部连接时,在我的情况下,它是管道组件的一部分,urllib 的情况只是我创建的基本测试用例,更一般的测试用例是我试图从内部下载 csv 数据这些 python 图像 pod,然后进行一些操作,因为它们是外部链接,所以我再次无法下载 csv 文件。
-
@Felipe 实际上端口和节点设置正确,因为 http 问题是 wget 特有的,我可以 curl http 和 https 协议网站,问题只是在尝试从 pod 内部连接时。
-
如果 /proc/sys/net/bridge/bridge-nf-call-iptables 文件尚未在 vm 中设置,请尝试将其设置为 1。 minikube 存在一些问题。这可能会有所帮助。 sudo echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptables
标签: docker kubernetes urllib minikube kubeflow