rancher 添加节点

Last updated on November 20, 2024 am

🧙 Questions

rancher2.8.5版本添加节点

☄️ Ideas

查看当前集群情况

kubectl get nodes

集群基础配置

  • 时区同步设置
  • 用户创建
  • hosts映射

下方安装包

scp -r ispong@master:/tmp/rancher /tmp

添加节点

sudo mkdir -p /data/rke2-artifacts
sudo cp /tmp/rancher/rke2-images.linux-amd64.tar.zst /data/rke2-artifacts/
sudo cp /tmp/rancher/rke2.linux-amd64.tar.gz /data/rke2-artifacts/
sudo cp /tmp/rancher/sha256sum-amd64.txt /data/rke2-artifacts/

# 必须要使用root用户执行
cd /tmp/rancher
INSTALL_RKE2_ARTIFACT_PATH=/data/rke2-artifacts INSTALL_RKE2_TYPE="agent" sh install.sh

启用agent服务

sudo systemctl enable rke2-agent.service

配置agent

sudo mkdir -p /etc/rancher/rke2/
sudo vim /etc/rancher/rke2/config.yaml

token获取,在master节点上查看
sudo cat /var/lib/rancher/rke2/server/node-token
使用内网ip或者域名,端口号一定是9345

server: https://isxcode:9345
token: K1037a329d597cb3222a2939e2a05a86ea52d40cc713d7ab3285f5237264699545b::server:c1d835d2739281ca0d1144c589290543
tls-san:
  - isxcode

启动agent服务

journalctl -u rke2-agent -f 查看日志

sudo systemctl start rke2-agent.service
sudo systemctl status rke2-agent.service

检测节点

kubectl get nodes

配置node的roles

kubectl label node slave kubernetes.io/role=worker --overwrite

20241008173042

labels:
  node-role.kubernetes.io/control-plane: 'true'
  node-role.kubernetes.io/etcd: 'true'
  node-role.kubernetes.io/master: 'true'
  node-role.kubernetes.io/worker: 'true'
[root@master ~]# kubectl get nodes
NAME     STATUS   ROLES                              AGE    VERSION
master   Ready    control-plane,etcd,master,worker   138m   v1.28.12+rke2r1
slave    Ready    worker                             35m    v1.28.12+rke2r1

配置harbor仓库

mkdir -p /data/harbor/
scp -r root@master:/data/harbor/ssl /data/harbor/
sudo vim /etc/rancher/rke2/registries.yaml
mirrors:
  docker.io:
    endpoint:
      - "https://isxcode:8443"
configs:
  "https://isxcode:8443":
    auth:
      username: admin
      password: Harbor12345
    tls:
      cert_file: /data/harbor/ssl/isxcode.cert
      key_file: /data/harbor/ssl/isxcode.key
      ca_file: /data/harbor/ssl/ca.crt
sudo systemctl restart rke2-agent.service

rancher 添加节点
https://ispong.isxcode.com/kubernetes/rancher/rancher 添加节点/
Author
ispong
Posted on
October 8, 2024
Licensed under