后面代理Kubernetes Docker容器(Kubernetes Docker Containe

2019-10-28 22:36发布

我们已经部署了Kubernetes集群背后的代理,并配置成功泊坞窗守护进程来使用我们的代理如下面的页面描述蒲凌图片: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy

我们已经配置了多克尔客户端设置environemnt PARAMATERS“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

泊坞窗容器手动运行- 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荚- ENV参数没有设置

以上用作Kubernetes POD相同搬运工图像不具有代理环境PARAMATERS(同机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 /泊坞窗,代理环境参数是为荚设置是否正确?

非常感谢你!

Answer 1:

这种状态的原因是,与代理环境变量是泊坞窗客户端的功能。 码头工人分为两个部分:API暴露对码头工人守护程序并使用其可以运行集装箱码头工人码头工人跑客户CLI插座....所以该命令会打码头工人守护程序API使“东西”。 可悲的是Kubernetes是另一个API客户端是什么意思是Kubernetes不使用泊坞窗客户安排集装箱(直接使用SDK Kubernetes访问API),所以这就是为什么你没有看到预期的环境变量。

要解决这个问题,我建议要与代理值如创建ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: your-config-map-name
  labels:
    app: your-best-app
data:
  HTTPS_PROXY: http://ssnproxy.ssn.xxx.com:80/
  HTTP_PROXY: http://ssnproxy.ssn.xxx.com:80/

和环境变量使用它们安装到部署

envFrom:
  - configMapRef:
      name: your-config-map-name


文章来源: Kubernetes Docker Containers behind proxy