1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
| ##操作系统层
写入 /etc/profile:
vi /etc/profile
追加:
export HTTP_PROXY=http://代理IP:端口
export HTTPS_PROXY=http://代理IP:端口
export NO_PROXY=localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16,.svc,.cluster.local
生效:
source /etc/profile
##systemd 全局层
很多服务不会读 /etc/profile
配置:
/etc/systemd/system.conf
/etc/systemd/user.conf
添加:
DefaultEnvironment="HTTP_PROXY=http://IP:PORT"
DefaultEnvironment="HTTPS_PROXY=http://IP:PORT"
DefaultEnvironment="NO_PROXY=localhost,127.0.0.1"
然后:
systemctl daemon-reexec
👉 作用:
kubelet
containerd
docker(如果有)
##配置 containerd 代理
编辑:
mkdir -p /etc/systemd/system/containerd.service.d
vi /etc/systemd/system/containerd.service.d/http-proxy.conf
写入:
[Service]
Environment="HTTP_PROXY=http://代理IP:端口"
Environment="HTTPS_PROXY=http://代理IP:端口"
Environment="NO_PROXY=localhost,127.0.0.1,10.244.0.0/16,10.96.0.0/12,.svc,.cluster.local"
重启:
systemctl daemon-reexec
systemctl restart containerd
验证 containerd:
crictl pull nginx:latest
##kubelet
路径:
/etc/systemd/system/kubelet.service.d/10-proxy.conf
[Service]
Environment="HTTP_PROXY=http://IP:PORT"
Environment="HTTPS_PROXY=http://IP:PORT"
Environment="NO_PROXY=127.0.0.1,localhost,10.0.0.0/8,10.96.0.0/12,10.244.0.0/16,.svc,.cluster.local"
重启:
systemctl daemon-reexec
systemctl restart kubelet
👉 作用:
Pod DNS / API Server 通信
镜像拉取间接链路
##Helm
Helm 需要:
export HTTP_PROXY=...
export HTTPS_PROXY=...
或者:
helm repo add ...
👉 注意:
Helm 只吃环境变量,不吃 systemd
##containerd 镜像拉取链路
除了 systemd proxy,还要:
/etc/containerd/config.toml(重点)
有些环境需要加 mirror:
[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/etc/containerd/certs.d"
或者:
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://mirror.aliyuncs.com"]
|