Add K3s containerd proxy config

This commit is contained in:
hermes-bot
2026-05-30 02:03:05 +00:00
parent c09b23df6e
commit 5cd3ecd5e5

View File

@@ -60,6 +60,28 @@ git config --global http.proxy http://用户名:密码@东京服务器IP:3128
git config --global https.proxy http://用户名:密码@东京服务器IP:3128 git config --global https.proxy http://用户名:密码@东京服务器IP:3128
``` ```
### K3s (containerd) 配置
K3s 默认使用 containerd不走 systemd代理需要在 k3s service 环境变量中配置。
```bash
# 添加代理环境变量到 k3s service
mkdir -p /etc/systemd/system/k3s.service.d
cat > /etc/systemd/system/k3s.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://用户名:密码@东京服务器IP:3128"
Environment="HTTPS_PROXY=http://用户名:密码@东京服务器IP:3128"
Environment="NO_PROXY=localhost,127.0.0.1,10.0.0.0/8,.svc,.cluster.local"
EOF
systemctl daemon-reload && systemctl restart k3s
```
验证:
```bash
crictl pull nginx
kubectl run nginx --image=nginx
```
### 取消代理(如需直连) ### 取消代理(如需直连)
```bash ```bash
git config --global --unset http.proxy git config --global --unset http.proxy