K8s proxy configuration
December 11, 2024Less than 1 minute
Overview
Sometimes k8s containerd can not pull images, we need to configure the proxy.
Solution
configure proxy using systemctl
sudo systemctl set-environment HTTP_PROXY=127.0.0.1:7890
sudo systemctl set-environment HTTPS_PROXY=127.0.0.1:7890
sudo systemctl set-environment NO_PROXY=localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local,.ewhisper.cn,<nodeCIDR>,<APIServerInternalURL>,<serviceNetworkCIDRs>,<etcdDiscoveryDomain>,<clusterNetworkCIDRs>,<platformSpecific>,<REST_OF_CUSTOM_EXCEPTIONS>
sudo systemctl restart containerd
sudo systemctl unset-environment HTTP_PROXY
sudo systemctl unset-environment HTTPS_PROXY
sudo systemctl unset-environment NO_PROXY
sudo systemctl restart containerd
Create /etc/systemd/system/containerd.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local,.ewhisper.cn,<nodeCIDR>,<APIServerInternalURL>,<serviceNetworkCIDRs>,<etcdDiscoveryDomain>,<clusterNetworkCIDRs>,<platformSpecific>,<REST_OF_CUSTOM_EXCEPTIONS>"
sudo systemctl daemon-reload
sudo systemctl restart containerd