KubeKey添加新节点

KubeSphere 使用一段时间之后,由于工作负载不断增加,可能需要水平扩展集群。自 KubeSphere v3.0.0 起,可以使用全新的安装程序 KubeKey 将新节点添加到集群。从根本上说,该操作是基于 Kubelet 的注册机制。换言之,新节点将自动加入现有的 Kubernetes 集群。

1、工作准备

准备工作参考【https://www.cnblogs.com/sxFu/p/17921965.html】

2、添加工作节点

使用 KubeKey 检索集群信息。以下命令会创建配置文件 (sample.yaml)

./kk create config --from-cluster

在配置文件中,将新节点的信息放在 hosts 和 roleGroups 之下。该示例添加了两个新节点(即 node1 和 node2)。这里的 master是现有节点。

apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  ##You should complete the ssh information of the hosts
  - {name: master, address: 192.168.43.128, internalAddress: 192.168.43.128, user: root, password: passwd}
  - {name: node1, address: 192.168.43.129, internalAddress: 192.168.43.129, user: root, password: passwd}
  - {name: node2, address: 192.168.43.130, internalAddress: 192.168.43.130, user: root, password: passwd}
  roleGroups:
    etcd:
    - master
    master:
    - master
    worker:
    - node1
    - node2
  controlPlaneEndpoint:
    ##Internal loadbalancer for apiservers
    #internalLoadbalancer: haproxy

    ##If the external loadbalancer was used, 'address' should be set to loadbalancer's ip.
    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.22.12
    clusterName: cluster.local
    proxyMode: ipvs
    masqueradeAll: false
    maxPods: 110
    nodeCidrMaskSize: 24
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    privateRegistry: ""
  • 有关更多配置文件的信息,请参见编辑配置文件

  • 添加新节点时,请勿修改现有节点的主机名。

  • 用自己的主机名替换示例中的主机名。

执行以下命令

./kk add nodes -f sample.yaml

安装完成后,将能够在 KubeSphere 的控制台上查看新节点及其信息。在集群管理页面,选择左侧菜单节点下的集群节点,或者执行命令 kubectl get node 以检查更改。

 

【参考:https://www.kubesphere.io/zh/docs/v3.4/installing-on-linux/cluster-operation/add-new-nodes/】

 

posted @ 2023-12-29 10:42  sxFu9528  阅读(114)  评论(0编辑  收藏  举报