我们确实已经在代理后面部署了一个 Kubernetes 集群,并成功配置了 docker 守护程序以使用我们的代理来提取图像,如下页所述:https ://docs.docker.com/config/daemon/systemd/#httphttps-proxy
我们确实已经配置了 Docker 客户端以设置环境参数“https_proxy”、“http_proxy”和“no_proxy”,如下页中所定义:https ://docs.docker.com/network/proxy/#configure-the-docker -客户
Kubernetes集群设置如下:
aadigital1:~ # kubectl get node
NAME STATUS ROLES AGE VERSION
aadigital1 Ready master,node 9d v1.10.4
aadigital2 Ready node 9d v1.10.4
aadigital3 Ready node 9d v1.10.4
aadigital4 Ready node 9d v1.10.4
aadigital5 Ready node 9d v1.10.4
Docker 容器手动运行 - ENV 参数设置正确
手动部署的 docker 容器的环境参数设置如下:
aadigital1:~ # docker run -i -t odise/busybox-curl ash
/ # printenv
HTTPS_PROXY=http://ssnproxy.ssn.xxx.com:80/
no_proxy=localhost,127.0.0.0,127.0.1.1,127.0.1.1,local.home,80.250.142.64,80.250.142.65,80.250.142.66,80.250.142.69,80.250.142.70,80.250.142.71,aadigital1.aan.xxx.com,aadigita2.ssn.xxx.com,aadigital3.ssn.xxx.com,aadigital4.ssn.xxx.com,aadigita5.ssn.xxx.com,aadigital6.ssn.xxx.com
HOSTNAME=0360a9dcd20b
SHLVL=1
HOME=/root
NO_PROXY=localhost,127.0.0.0,127.0.1.1,127.0.1.1,local.home,80.250.142.64,80.250.142.65,80.250.142.66,80.250.142.69,80.250.142.70,80.250.142.71,aadigital1.aan.xxx.com,aadigita2.ssn.xxx.com,aadigital3.ssn.xxx.com,aadigital4.ssn.xxx.com,aadigita5.ssn.xxx.com,aadigital6.ssn.xxx.com
https_proxy=http://ssnproxy.ssn.xxx.com:80/
http_proxy=http://ssnproxy.ssn.xxx.com:80/
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
HTTP_PROXY=http://ssnproxy.ssn.xxx.com:80/
Kubernetes POD - 未设置 ENV 参数
上面用作 Kubernetes POD 的同一 docker 映像没有代理环境参数(同一台机器 aadigital1):
aadigital1:~ # kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
busybox-6d4df8f8b7-m62m2 1/1 Running 3 2d 10.0.0.16 aadigital3
busybox-curl 1/1 Running 0 16m 10.0.1.59 aadigital1
busybox-dns 1/1 Running 9 6h 10.0.1.53 aadigital1
aadigital1:~ # kubectl exec -it busybox-curl -- ash
/ # printenv
KUBERNETES_PORT=tcp://10.0.128.1:443
NGINX_NODEPORT_PORT=tcp://10.0.204.167:80
KUBERNETES_SERVICE_PORT=443
NGINX_NODEPORT_SERVICE_PORT=80
HOSTNAME=busybox-curl
SHLVL=1
HOME=/root
NGINX_NODEPORT_PORT_80_TCP_ADDR=10.0.204.167
NGINX_NODEPORT_PORT_80_TCP_PORT=80
NGINX_NODEPORT_PORT_80_TCP_PROTO=tcp
TERM=xterm
NGINX_NODEPORT_PORT_80_TCP=tcp://10.0.204.167:80
KUBERNETES_PORT_443_TCP_ADDR=10.0.128.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP=tcp://10.0.128.1:443
KUBERNETES_SERVICE_PORT_HTTPS=443
PWD=/
KUBERNETES_SERVICE_HOST=10.0.128.1
NGINX_NODEPORT_SERVICE_HOST=10.0.204.167
我们如何配置 Kubernetes / Docker 以便为 POD 正确设置代理环境参数?
非常感谢你!