如何使用国内资源安装 Rancher

安装 Rancher 所需资源:

  • Rancher 依赖的容器镜像,默认:docker.io

高可用模式安装 Rancher(Helm 安装 Rancher)

helm install rancher rancher-latest/rancher \
  --namespace cattle-system \
  --set hostname=192.168.205.106.sslip.io \
  --set replicas=1 \
  --set bootstrapPassword=admin \
  --set rancherImage=registry.cn-hangzhou.aliyuncs.com/rancher/rancher \
  --set systemDefaultRegistry=registry.cn-hangzhou.aliyuncs.com
  • rancherImage:指定 rancher 镜像
  • systemDefaultRegistry:设置系统默认镜像仓库

参考:rancher/chart/values.yaml at v2.8.4 · rancher/rancher · GitHub

Rancher 启动成功后,进入到 local 集群查看运行的 pod,均为 registry.cn-hangzhou.aliyuncs.com 镜像:

创建 RKE2/K3S 集群时,Container Registry 默认为:registry.cn-hangzhou.aliyuncs.com

root@demo-2:~# /var/lib/rancher/rke2/bin/crictl image
IMAGE                                                                                        TAG                                        IMAGE ID            SIZE
registry.cn-hangzhou.aliyuncs.com/rancher/fleet-agent                                        v0.9.4                                     ce783a0ca33f0       107MB
registry.cn-hangzhou.aliyuncs.com/rancher/hardened-cluster-autoscaler                        v1.8.10-build20240124                      cd00dc5289588       12MB
registry.cn-hangzhou.aliyuncs.com/rancher/hardened-coredns                                   v1.11.1-build20240305                      00df8b41cfd2e       23.5MB
registry.cn-hangzhou.aliyuncs.com/rancher/hardened-etcd                                      v3.5.9-k3s1-build20240418                  7893f7425a52a       16.6MB
registry.cn-hangzhou.aliyuncs.com/rancher/hardened-k8s-metrics-server                        v0.7.1-build20240401                       6d80f01a1966b       18.4MB
registry.cn-hangzhou.aliyuncs.com/rancher/hardened-kubernetes                                v1.28.9-rke2r1-build20240416               8fae8e1e0c868       175MB
registry.cn-hangzhou.aliyuncs.com/rancher/klipper-helm                                       v0.8.3-build20240228                       0929b4140ada6       91.2MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-cni                                v3.27.3                                    6527a35581401       88.4MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-kube-controllers                   v3.27.3                                    3e4fd05c0c1c0       33.4MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-node                               v3.27.3                                    5c6ffd2b2a1d0       116MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-operator                           v1.32.7                                    ac4b460566ae9       21.4MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-pod2daemon-flexvol                 v3.27.3                                    ab5b4f1ca2893       7.59MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-typha                              v3.27.3                                    b542f80277bc5       29.6MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-ingress-nginx-kube-webhook-certgen        v20230312-helm-chart-4.5.2-28-g66a760794   5a86b03a88d23       20.1MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-pause                                     3.6                                        6270bb605e12e       298kB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-sig-storage-snapshot-controller           v6.2.1                                     1ef6c138bd5f2       24.2MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-sig-storage-snapshot-validation-webhook   v6.2.2                                     ff52c2bcf9f88       21.1MB
registry.cn-hangzhou.aliyuncs.com/rancher/nginx-ingress-controller                           nginx-1.9.6-hardened1                      3f5b7fd2026e9       325MB
registry.cn-hangzhou.aliyuncs.com/rancher/rancher-agent                                      v2.8.4                                     ed9ac6cfe6db5       519MB
registry.cn-hangzhou.aliyuncs.com/rancher/rke2-cloud-provider                                v1.29.3-build20240412                      3525a3daa55c9       68MB
registry.cn-hangzhou.aliyuncs.com/rancher/rke2-runtime                                       v1.28.9-rke2r1                             cbd54504b9c4a       108MB
registry.cn-hangzhou.aliyuncs.com/rancher/system-agent                                       v0.3.6-suc                                 00511613dec56       32.4MB
registry.cn-hangzhou.aliyuncs.com/rancher/system-upgrade-controller                          v0.13.1                                    abc5338582c4f       10.7MB

创建 RKE 集群,需要手动设置 Private Registry 为:registry.cn-hangzhou.aliyuncs.com

root@demo-3:~# docker images
REPOSITORY                                                                              TAG                    IMAGE ID       CREATED         SIZE
registry.cn-hangzhou.aliyuncs.com/rancher/rancher-agent                                 v2.8.4                 ed9ac6cfe6db   10 days ago     1.12GB
registry.cn-hangzhou.aliyuncs.com/rancher/rancher-webhook                               v0.4.5                 2015c2094775   2 weeks ago     82.8MB
registry.cn-hangzhou.aliyuncs.com/rancher/shell                                         v0.1.24                deabd25af88c   3 weeks ago     393MB
registry.cn-hangzhou.aliyuncs.com/rancher/fleet-agent                                   v0.9.4                 ce783a0ca33f   3 weeks ago     297MB
registry.cn-hangzhou.aliyuncs.com/rancher/hyperkube                                     v1.28.9-rancher1       9054b61bcaeb   5 weeks ago     1.75GB
registry.cn-hangzhou.aliyuncs.com/rancher/kube-api-auth                                 v0.2.1                 61e101ca176a   3 months ago    96.2MB
registry.cn-hangzhou.aliyuncs.com/rancher/nginx-ingress-controller                      nginx-1.9.6-rancher1   aba045951c44   3 months ago    236MB
registry.cn-hangzhou.aliyuncs.com/rancher/calico-cni                                    v3.27.0-rancher1       491835dde8c1   4 months ago    215MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-flannel-flannel                      v0.24.2                f9c73fde068f   4 months ago    76.1MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-metrics-server                       v0.7.0                 b9a5a1927366   4 months ago    66.8MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-ingress-nginx-kube-webhook-certgen   v20231226-1a7112e06    eb825d2bb76b   5 months ago    53.6MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-kube-controllers              v3.27.0                4e87edec0297   5 months ago    75.5MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-calico-node                          v3.27.0                1843802b91be   5 months ago    340MB
registry.cn-hangzhou.aliyuncs.com/rancher/rke-tools                                     v0.1.96                d236cd628d15   6 months ago    319MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-coreos-etcd                          v3.5.10                42d0b9aa7106   7 months ago    57.6MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-cluster-proportional-autoscaler      v1.8.9                 2635ad6e71aa   10 months ago   38MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-coredns-coredns                      1.10.1                 ead0a4a53df8   15 months ago   53.6MB
registry.cn-hangzhou.aliyuncs.com/rancher/mirrored-pause                                3.7                    221177c6082a   2 years ago     711kB

单节点模式安装 Rancher

可以通过环境变量 CATTLE_SYSTEM_DEFAULT_REGISTRY 来设置 system-default-registry 参数。以下是一个示例命令:

docker run -d --restart=unless-stopped \
  -p 80:80 -p 443:443 \
  --privileged \
  -e CATTLE_SYSTEM_DEFAULT_REGISTRY=registry.cn-hangzhou.aliyuncs.com \
  --name rancher \
  registry.cn-hangzhou.aliyuncs.com/rancher/rancher:v2.8.4
3 个赞

感谢楼主
今天发现rancher webhook自动更新0.4.6,但是aliyun上没有镜像
请问下这个镜像库是官方会长期更新同步的么

有的

是的 刚才看已经有了
不知道同步策略是怎么样的

1 */24 * * *

您好,按照您提供的方式进行docker容器内安装,启动过程中出现这个报错是什么原因嘞,环境是centos7.9,docker版本24.0.9

创建个新话题提交吧,把详细的上下文都写清楚


单节点安装是不是在node上安装,安装完,我怎么看不到这个工具
image

你创建个新话题,将你的问题描述清楚,不要在这个话题下跟帖

国内网络使用docker部署

docker run -d --restart=unless-stopped --privileged -p 10080:80 -p 10443:443 -e TZ=Asia/Shanghai -e CATTLE_SYSTEM_DEFAULT_REGISTRY=registry.cn-hangzhou.aliyuncs.com -e CATTLE_BOOTSTRAP_PASSWORD=rancher -v /data/rancher:/var/lib/rancher registry.cn-hangzhou.aliyuncs.com/rancher/rancher:v2.9.0

local集群会报错,并在创建rke2自定义集群时不成功,会卡住。
试了v2.9.0 v2.8.6 v2.8.5都一样的问题


创建一个新话题吧,别在这个话题下面回复

请问下,这个解决了吗

解决了,看这个帖子

https://forums.rancher.cn/t/docker-run-rancher-rancher-mirrored-pause/3546