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
相关推荐
comedate20 小时前
Windows / Linux GPU 虚拟内存布局差异与 CUDA 越界访问行为
linux·windows·mmu·cuda 越界访问
暴力求解21 小时前
Linux网络---传输层协议TCP(二)
linux·服务器·开发语言·网络·tcp/ip
JoyCong19981 天前
ToDesk个人版、专业版、游戏版、设计版、性能版、团队版权益介绍
大数据·运维·游戏·远程工作·远程操作
ltl1 天前
序列化格式深度对比:Protobuf、FlatBuffers、Cap’n Proto
linux
lengjingzju1 天前
编译与调试完全指南—第17章 总结
linux
ltl1 天前
容器网络性能真相:veth vs macvlan vs eBPF 数据面
linux
Elastic 中国社区官方博客1 天前
ES95:面向 Elasticsearch 时间序列指标的自适应压缩
大数据·运维·elasticsearch·搜索引擎·架构·全文检索
我不会插花弄玉1 天前
9.进程间通信(上)【由浅入深-Linux】
linux·共享内存·进程通信
mqiqe1 天前
AgentScope Java 2.0 Agent 状态存储(AgentStateStore)深度解析:构建可恢复、可扩展的智能体运行时
java·运维·网络
mennekes1 天前
数据中心安全配电设备如何选择?
运维·人工智能·科技·安全·制造