概述
本文会介绍在部署 RKE2 集群时,关于 registries.yaml
文件配置的一些用法。
配置 Docker 镜像源
1 2 3 4
| mirrors: docker.io: endpoint: - "https://docker.m.daocloud.io"
|
配置用户密码
1 2 3 4 5
| configs: "harbor.zerchin.xyz": auth: username: admin password: password
|
配置私有证书
1 2 3 4 5 6
| configs: "harbor.zerchin.xyz": tls: cert_file: /etc/rancher/rke2/tls/ca.crt key_file: /etc/rancher/rke2/tls/tls.key ca_file: /etc/rancher/rke2/tls/tls.crt
|
跳过 TLS 认证
1 2 3 4
| configs: "harbor.zerchin.xyz": tls: insecure_skip_verify: true
|
重写镜像位置
- 给镜像重写到一个新的项目中:
例如将docker.io/library/busybox
镜像,重写成harbor.zerchin.xyz/public-docker-proxy/library/busybox
这个地址进行拉取
1 2 3 4 5 6
| mirrors: docker.io: endpoint: - "https://harbor.zerchin.xyz" rewrite: "(^.+$)": "public-docker-proxy/$1"
|
- 给镜像的项目名进行重写:
例如将docker.io
下所有的 library
仓库的镜像,重写成harbor.zerchin.xyz/mypro/public-images
这个地址进行拉取
1 2 3 4 5 6
| mirrors: docker.io: endpoint: - "https://harbor.zerchin.xyz" rewrite: "^library/(.*)": "mypro/public-images/$1"
|
- 给镜像的版本 tag 进行重写:
例如将nginx:1.21
改写成nginx:patched-1.21
1 2 3 4 5 6
| mirrors: docker.io: endpoint: - "https://harbor.zerchin.xyz" rewrite: "^(.*):(.*)": "$1:patched-$2"
|
使用 http 地址
1 2 3 4
| mirrors: docker.io: endpoint: - "http://harbor.zerchin.xyz:5000"
|
使用 http 和用户登录
1 2 3 4 5 6 7 8 9
| mirrors: docker.io: endpoint: - "http://harbor.zerchin.xyz:5000" configs: "registry.example.com:5000": auth: username: admin password: password
|