K3S学习笔记

2025年1月10日 0 条评论 848 次阅读 0 人点赞

1.安装

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -

增加 node 时可以

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -

查看token

cat /var/lib/rancher/k3s/server/node-token

2. 设置 docker 的国内镜像

k3s 文件:/etc/rancher/k3s/registries.yaml

mirrors:
  docker.io:
    endpoint:
      - "https://docker.1panel.live"
      - "https://registry.cn-hangzhou.aliyuncs.com/"
  quay.io:
    endpoint:
      - "https://quay.tencentcloudcr.com/"
  registry.k8s.io:
    endpoint:
      - "https://registry.aliyuncs.com/v2/google_containers"
  gcr.io:
    endpoint:
      - "https://gcr.m.daocloud.io/"
  k8s.gcr.io:
    endpoint:
      - "https://registry.aliyuncs.com/google_containers"
  ghcr.io:
    endpoint:
      - "https://ghcr.m.daocloud.io/"

docker 如果是 snap 安装,文件: /var/snap/docker/current/config/daemon.json ,如果是 apt 或者 yum 安装,文件: /etc/docker/daemon.json

{
    "log-level":        "error", // 可选
    "registry-mirrors": [
        "https://docker.1panel.live",
        "https://docker.m.daocloud.io",
        "https://registry.cn-beijing.aliyuncs.com"
    ]
}

3. 重启 docker 服务。snap安装,snap restart docker。apt或者yum安装,systemctl restart docker

guojia

这个人太懒什么东西都没留下