Ubuntu 24.04 安装 k3s

配置镜像加速

sudo vi /etc/rancher/k3s/registries.yaml

mirrors:
  docker.io:
    endpoint:
      - "https://docker.1ms.run"
      - "https://docker.xuanyuan.me"
  registry.k8s.io:
    endpoint:
      - "https://docker.1ms.run"
      - "https://docker.xuanyuan.me"
  "192.168.0.100:5000":
    endpoint:
      - "http://192.168.0.100:5000"
  "192.168.0.67:5000":
    endpoint:
      - "http://192.168.0.67:5000"
configs:
  "192.168.0.100:5000":
    tls:
      insecure_skip_verify: true
  "192.168.0.67:5000":
    auth:
      username: admin
      password: "123456"
    tls:
      insecure_skip_verify: true

安装

# 安装 server 节点
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -

# server 节点查看 token
sudo cat /var/lib/rancher/k3s/server/node-token

# 安装 agent 节点
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -

# 常用命令
sudo kubectl get nodes -o wide
sudo kubectl get pods -A