website/content/zh/docs/v4.1/03-installation-and-upgrade/05-add-and-delete-cluster-n.../01-add-cluster-nodes.adoc
zhuxiujuan28 ff10ded70a fix 4.1 conflicts
Signed-off-by: zhuxiujuan28 <562873187@qq.com>
2024-09-11 09:56:32 +08:00

131 lines
5.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "添加集群节点"
linkTitle: "添加集群节点"
keywords: "Kubernetes, KubeSphere, 添加集群节点"
description: "介绍如何添加 KubeSphere 集群节点。"
weight: 01
---
本节介绍如何添加{ks_product_both}集群节点。
节点添加过程中将用到开源工具 KubeKey。有关 KubeKey 的更多信息,请访问 link:https://github.com/kubesphere/kubekey[GitHub KubeKey 仓库]。
// Note
include::../../../../_ks_components/admonitions/note.adoc[]
本节介绍的节点添加方式仅适用于 Kubernetes 通过 KubeKey 安装的场景。如果您的 Kubernetes 不是通过 KubeKey 安装,请参阅 link:https://kubernetes.io/zh/docs/concepts/architecture/nodes/[Kubernetes 官方文档]添加节点。
include::../../../../_ks_components/admonitions/admonEnd.adoc[]
== 前提条件
* 新增节点的操作系统和版本须为 Ubuntu 16.04、Ubuntu 18.04、Ubuntu 20.04、Ubuntu 22.04、Debian 9、Debian 10、CentOS 7、CentOS Stream、RHEL 7、RHEL 8、SLES 15 或 openSUSE Leap 15。多个集群节点的操作系统可以不同。关于其它操作系统和版本支持请联系{ks_product_both}技术支持。
* 为确保集群具有足够的计算和存储资源,建议新增节点配置至少 8 个 CPU 核心16 GB 内存和 200 GB 磁盘空间。除此之外,建议在每台集群节点的 **/var/lib/docker**(对于 Docker或 **/var/lib/containerd**(对于 containerd 目录额外挂载至少 200 GB 磁盘空间用于存储容器运行时数据。
* 如果添加控制平面节点,您需要提前为集群配置高可用性。如果您使用负载均衡器,请确保负载均衡器监听所有控制平面节点的 6443 端口。有关更多信息请参阅link:../../../03-installation-and-upgrade/01-preparations/03-configure-high-availability/[配置高可用性]。
// * 如果您的集群节点无法连接互联网,您还需要准备一台 Linux 服务器用于创建私有镜像服务,该服务器必须与{ks_product_both}集群节点网络连通并且在 **/mnt/registry** 目录挂载至少 100 GB 磁盘空间。
:relfileprefix: ../../../
* 您需要获取安装配置文件 **config-sample.yaml** 并将其传输到用于执行本节操作的集群节点。有关更多信息请参阅xref:03-installation-and-upgrade/02-install-kubesphere/02-install-kubernetes-and-kubesphere.adoc[安装 Kubernetes 和 KubeSphere]。
:relfileprefix: ./
--
// Warning
include::../../../../_ks_components/admonitions/warning.adoc[]
* 添加节点过程中不支持在 **config-sample.yaml** 配置文件中修改原有的集群配置。
* 如果您无法获取安装配置文件 **config-sample.yaml**您需要参阅link:../../02-install-kubesphere/02-install-kubernetes-and-kubesphere/[安装 Kubernetes 和 KubeSphere] 重新创建 **config-sample.yaml** 文件。重新创建该文件时,请务必确保文件中的集群信息与集群的当前实际情况一致。否则,添加节点后集群可能会出现错误。
include::../../../../_ks_components/admonitions/admonEnd.adoc[]
--
== 操作步骤
include::../../../_custom/installationAndUpgrade/installationAndUpgrade-oper-downloadKubekey.adoc[]
+
include::../../../_custom/installationAndUpgrade/installationAndUpgrade-oper-transferConfig.adoc[]
+
. 执行以下命令编辑安装配置文件 **config-sample.yaml**
+
--
// Bash
include::../../../../_ks_components/code/bash.adoc[]
vi config-sample.yaml
----
--
. 在 **config-sample.yaml** 文件的 **hosts** 参数下设置新增节点的信息。
+
--
include::../../../_custom/installationAndUpgrade/installationAndUpgrade-para-hosts.adoc[]
// Warning
include::../../../../_ks_components/admonitions/warning.adoc[]
请勿修改原有节点的信息。否则,添加节点后集群可能会出现错误。
include::../../../../_ks_components/admonitions/admonEnd.adoc[]
--
. 在 **config-sample.yaml** 文件的 **roleGroups** 参数下设置新增节点在集群中的角色。
+
--
include::../../../_custom/installationAndUpgrade/installationAndUpgrade-para-roleGroups.adoc[]
// Warning
include::../../../../_ks_components/admonitions/warning.adoc[]
请勿修改原有节点的角色。否则,添加节点后集群可能会出现错误。
include::../../../../_ks_components/admonitions/admonEnd.adoc[]
--
. 如果新增控制平面节点并且当前集群未配置高可用性,在 **config-sample.yaml** 文件的 **controlPlaneEndpoint** 参数下设置高可用性信息。
+
--
include::../../../_custom/installationAndUpgrade/installationAndUpgrade-para-controlPlaneEndpoint.adoc[]
// Warning
include::../../../../_ks_components/admonitions/warning.adoc[]
* 如果当前集群已配置高可用性,请勿修改 **config-sample.yaml** 文件中的高可用性信息。否则,添加节点后集群可能会出现错误。
* 如果当前集群使用本地负载均衡实现高可用性,您不需要对集群高可用性进行任何操作;如果当前集群使用负载均衡器实现高可用性,您只需要设置负载均衡器监听所有控制平面节点的 6443 端口。有关更多信息请参阅link:../../../03-installation-and-upgrade/01-preparations/03-configure-high-availability/[配置高可用性]。
include::../../../../_ks_components/admonitions/admonEnd.adoc[]
--
. 保存配置文件,执行以下命令开始添加节点:
+
--
include::../../../_custom/installationAndUpgrade/installationAndUpgrade-code-addNodes.adoc[]
--
// endif::[]
. 执行以下命令查看当前集群的节点:
+
--
// Bash
[,bash]
----
kubectl get node
----
如果显示新增节点的信息,则表明节点添加成功。
--