rancher安装--针对报错API Aggregation not ready

报错API Aggregation not ready

准备一个Dockerfile
c 复制代码
FROM rancher/rancher:stable

# 重命名原始入口脚本
RUN mv /usr/bin/entrypoint.sh /usr/bin/entrypoint-original.sh

# 创建包装入口脚本:在 k3s 启动前写入镜像源配置
RUN echo '#!/bin/sh'                                                         >  /usr/bin/entrypoint.sh && \
    echo 'mkdir -p /var/lib/rancher/k3s/agent/etc'                           >> /usr/bin/entrypoint.sh && \
    echo 'mkdir -p /etc/rancher/k3s'                                         >> /usr/bin/entrypoint.sh && \
    echo 'cat > /var/lib/rancher/k3s/agent/etc/registries.yaml << REGEOF'    >> /usr/bin/entrypoint.sh && \
    echo 'mirrors:'                                                          >> /usr/bin/entrypoint.sh && \
    echo '  "docker.io":'                                                    >> /usr/bin/entrypoint.sh && \
    echo '    endpoint:'                                                     >> /usr/bin/entrypoint.sh && \
    echo '      - "https://docker.m.daocloud.io"'                           >> /usr/bin/entrypoint.sh && \
    echo '      - "https://dockerproxy.com"'                                >> /usr/bin/entrypoint.sh && \
    echo '      - "https://mirror.aliyuncs.com"'                            >> /usr/bin/entrypoint.sh && \
    echo '  "rancher":'                                                      >> /usr/bin/entrypoint.sh && \
    echo '    endpoint:'                                                     >> /usr/bin/entrypoint.sh && \
    echo '      - "https://docker.m.daocloud.io"'                           >> /usr/bin/entrypoint.sh && \
    echo '      - "https://dockerproxy.com"'                                >> /usr/bin/entrypoint.sh && \
    echo '  "ghcr.io":'                                                     >> /usr/bin/entrypoint.sh && \
    echo '    endpoint:'                                                     >> /usr/bin/entrypoint.sh && \
    echo '      - "https://docker.m.daocloud.io"'                           >> /usr/bin/entrypoint.sh && \
    echo '  "registry.k8s.io":'                                             >> /usr/bin/entrypoint.sh && \
    echo '    endpoint:'                                                     >> /usr/bin/entrypoint.sh && \
    echo '      - "https://docker.m.daocloud.io"'                           >> /usr/bin/entrypoint.sh && \
    echo '  "quay.io":'                                                     >> /usr/bin/entrypoint.sh && \
    echo '    endpoint:'                                                     >> /usr/bin/entrypoint.sh && \
    echo '      - "https://docker.m.daocloud.io"'                           >> /usr/bin/entrypoint.sh && \
    echo 'REGEOF'                                                            >> /usr/bin/entrypoint.sh && \
    echo 'cp /var/lib/rancher/k3s/agent/etc/registries.yaml /etc/rancher/k3s/registries.yaml' >> /usr/bin/entrypoint.sh && \
    echo 'exec /usr/bin/entrypoint-original.sh "$@"'                         >> /usr/bin/entrypoint.sh && \
    chmod +x /usr/bin/entrypoint.sh

镜像构建运行

c 复制代码
# 1. 构建新镜像
docker build -t rancher-cn:latest .

# 2. 停掉旧容器、清理数据
docker stop rancher 2>/dev/null
docker rm rancher 2>/dev/null
rm -rf /opt/rancher/*

# 3. 运行
docker run -d --restart=unless-stopped \
  -p 80:80 -p 443:443 \
  --privileged \
  -v /opt/rancher:/var/lib/rancher \
  --name rancher \
  rancher-cn:latest

# 4. 等几秒后验证配置是否生效
sleep 5
docker exec rancher cat /var/lib/rancher/k3s/agent/etc/registries.yaml
docker exec rancher cat /etc/rancher/k3s/registries.yaml

# 5. 观察日志
docker logs -f rancher

检查确认

c 复制代码
# 等待 3-5 分钟后检查
docker exec rancher kubectl get pods -A
# coredns 应该变成 Running
docker exec rancher kubectl get pods -n kube-system
相关推荐
2301_77799834几秒前
Linux线程同步与互斥(三):信号量与环形队列实现生产者消费者模型
linux·c语言·c++
瞬间&永恒~3 分钟前
【MySQL】 InnoDB 锁等待排查与并发压测实验
运维·数据库·mysql
江湖有缘26 分钟前
Docker实战 | 使用Docker部署Donetick任务与家务管理应用
运维·docker·容器
实心儿儿35 分钟前
Linux —— 应用层协议HTTP
linux·网络·http
流星白龙39 分钟前
【Docker】4.NameSpace空间隔离实战
java·运维·docker
有续技术1 小时前
哈斯 (Haas) 机床 IP、端口号配置内容总结
运维·服务器
小张同学a.2 小时前
LAMP架构2
linux·运维·网络·架构·负载均衡
千河殇 多想和她2 小时前
如何在Reaonix中使用CodeGraph以及CodeGraph效果实测经验分享
linux·运维·ubuntu
VortMall2 小时前
出海引流运维双升级|VortMall微服务商城系统v1.3.12 升级更新
运维·微服务·facebook
心念枕惊2 小时前
新写了个直播录制工具,可录制抖音快手斗鱼直播
运维·服务器·数据库