附2:rke安装的k8s集群新增主机

转载说明:如果您喜欢这篇文章并打算转载它,请私信作者取得授权。感谢您喜爱本文,请文明转载,谢谢。


关联文章:

《附1:k8s服务器初始化》 

《RKE快速搭建离线k8s集群并用rancher管理界面》

rke安装的k8s集群新增主机

通过rancher界面创建的k8s集群,可以在rancher界面上编辑集群添加主机,但导入的k8s集群,需要通过命令行加入新主机。测试步骤如下:

1. 如《附1:k8s服务器初始化》中步骤,初始化新节点10.99.68.67

2. master1节点做到新worker节点的免秘钥:

ssh-copy-id 10.99.68.67

3. 将新worker节点的信息加入k8s-cluster.yaml

nodes:
 - address: 10.99.68.62 
 internal_address: 10.99.68.62 
 user: sre
 role: [controlplane, etcd]
 hostname_override: k8s-master01
 ssh_key_path: /home/sre/.ssh/id_rsa
 - address: 10.99.68.63
 internal_address: 10.99.68.63
 user: sre
 role: [controlplane, etcd]
 hostname_override: k8s-master02
 ssh_key_path: /home/sre/.ssh/id_rsa
 - address: 10.99.68.64
 internal_address: 10.99.68.64
 user: sre
 role: [controlplane, etcd]
 hostname_override: k8s-master03
 ssh_key_path: /home/sre/.ssh/id_rsa
 - address: 10.99.68.65
 internal_address: 10.99.68.65
 user: sre
 role: [worker]
 hostname_override: k8s-node01
 ssh_key_path: /home/sre/.ssh/id_rsa
 - address: 10.99.68.66
 internal_address: 10.99.68.66
 user: sre
 role: [worker]
 hostname_override: k8s-node02
 ssh_key_path: /home/sre/.ssh/id_rsa
 #新节点信息
 - address: 10.99.68.67
 internal_address: 10.99.68.67
 user: sre
 role: [worker]
 hostname_override: k8s-node03
 ssh_key_path: /home/sre/.ssh/id_rsa
private_registries:
 - url: harbor.test.com:8000   #私人harbor仓库地址
 is_default: true
services:
 etcd:
 backup_config:
 enabled: true
 interval_hours: 6
 retention: 60

4. 执行rke命令重新加载yml文件,添加新节点

rke up --update-only --config k8s-cluster.yml 

5. 查看k8s集群节点,新节点添加成功

[sre@k8s-master01 .kube]$ kubectl  get node
NAME           STATUS   ROLES               AGE   VERSION
k8s-master01   Ready    controlplane,etcd   41m   v1.20.6
k8s-master02   Ready    controlplane,etcd   31m   v1.20.6
k8s-master03   Ready    controlplane,etcd   31m   v1.20.6
k8s-node01     Ready    worker              20m   v1.20.6
k8s-node02     Ready    worker              20m   v1.20.6
k8s-node03     Ready    worker              2m    v1.20.6  #新节点
[sre@k8s-master01 .kube]$

查看rancher界面,也能看到主机添加成功。

你可能感兴趣的:(k8s&docker,kubernetes,docker,容器,k8s,添加主机)