This page looks best with JavaScript enabled

Configuring a Proxy for Kubernetes

 ·  ☕ 1 min read

Usually, running a command of the form export http_proxy/https_proxy on the host is enough to set a Proxy. However, settings on the host do not take effect inside containers. Below are several configuration approaches.

1. Configure Docker’s proxy - Node level

Configure this on the node that needs the Proxy. Docker is used as the example below:

  • Create the configuration file
1
2
mkdir -p /etc/systemd/system/docker.service.d
touch /etc/systemd/system/docker.service.d/https-proxy.conf
  • Edit the configuration file and set the proxy
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=https://proxy.example.com:443/"
Environment="NO_PROXY=localhost,127.0.0.1"
  • Restart Docker
1
2
systemctl daemon-reload
systemctl restart docker

2. Configure Proxy in containers - Container level

Configure this in the container that needs the Proxy.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
spec:
  containers:
    - env:
        - name: HTTP_PROXY
          value: "http://proxy.example.com:80/"
        - name: HTTPS_PROXY
          value: "HTTPS_PROXY=https://proxy.example.com:443/"
        - name: http_proxy
          value: "http://proxy.example.com:80/"
        - name: https_proxy
          value: "HTTPS_PROXY=https://proxy.example.com:443/"
        - name: no_proxy
          value: "localhost,127.0.0.1"

3. References


WeChat Official Account
WRITTEN BY
WeChat Official Account