k3s 私有倉庫問題
現象
- 配置
/etc/rancher/k3s/registries.yaml但是依舊無法使用私有鏡像倉庫(http) /var/lib/rancher/k3s/agent/etc/containerd/config.toml也沒有生成 私有鏡像倉庫配置

坑
在初始化 k3s 的時候,不能使用 --private-registry 參數,使用這個參數,就不會使用 /etc/rancher/k3s/registries.yaml 文件生成新的 contained 配置文件 /var/lib/rancher/k3s/agent/etc/containerd/config.toml
解決方案:
k3s 啟動命令
INSTALL_K3S_SKIP_DOWNLOAD=true \
INSTALL_K3S_EXEC='server --bind-address=192.168.1.1 --write-kubeconfig=/root/.kube/config --write-kubeconfig-mode=644 --node-label asrole=worker --no-flannel' \
./k3s-install.sh
registries.yaml 文件
mirrors:
registry.my.io: # 這里並不是像官方寫的那樣,docker.io 為 key endpoint 為私有倉庫其實是一種鏡像加速的意思
endpoint:
- "http://registry.my.io"
configs:
"registry.my.io": # 如果倉庫是完全開放沒有私有項目的則不需要配置 configs
auth:
username: admin
password: Harbor12345
