How to set proxy settings (http_proxy variables) for kubernetes (v1.11.2) cluster? How to set proxy settings (http_proxy variables) for kubernetes (v1.11.2) cluster? kubernetes kubernetes

How to set proxy settings (http_proxy variables) for kubernetes (v1.11.2) cluster?


You can add http_proxy setting to your Docker machine in order to forward packets from the nested Pod container through the target proxy server.

For Ubuntu based operating system:

Add export http_proxy='http://<host>:<port>' record to the file /etc/default/docker

For Centos based operating system:

Add export http_proxy='http://<host>:<port>' record to the file /etc/sysconfig/docker

Afterwards restart Docker service.


So I figured it out that to set the proxy for particular containers, set the env variable in Dockerfile.

ENV HTTP_PROXY http://10.x.x.x:PORT


For the docker service, use the systemd settings files:

Create a file:

/etc/systemd/system/docker.service.d/http-proxy.conf

With the content:

[Service]Environment="HTTP_PROXY=http://10.x.x.x:3128"Environment="HTTPS_PROXY=http://10.x.x.x:3128"

(you could also include NO_PROXY variables)

You'll need to reload systemctl and restart the docker service:

systemctl daemon-reloadsystemctl restart docker

For the containers to be able to connect to the proxy use /etc/default/docker or /etc/sysconfig/docker as mk_sta said.