在 Bare Metal 上,需要运行两次 create。第一次运行会构建安装 ISO,然后停止。接着,使用该 ISO 注册主机并将其分配到池。第二次运行会安装集群。
前提条件
操作步骤
1. 写入 install-config.yaml
在 bootstrap 节点上创建安装目录,例如 /root/global-install,并在其中写入 install-config.yaml。本页中的命令将此目录称为 <install-dir>;请参阅安装目录。确保文件为私有文件(chmod 600 install-config.yaml)。
复制以下模板并填写占位符。编号行特定于 Bare Metal,相关说明见模板下方的表格。关于其他字段,请参阅通用 install-config.yaml 字段。关于 ac 根据此文件渲染的对象,请参阅渲染的清单。
install-config.yaml
global:
bootstrapIP: <bootstrap-node-ip>
registry:
address: <host>:<port>
username: <user>
password: <password>
platform:
address: <platform-domain-or-ip>
username: admin@cpaas.io
password: <password>
extraAddresses: []
cert:
certificateFile: <console-cert-file>
privateKeyFile: <console-key-file>
# pkcs12CertificateFile: <console-pkcs12-file>
# pkcs12Password: <password>
cluster:
sshKeys:
- <ssh-public-key>
ntpServers: []
network:
podCIDR: 10.199.0.0/16
serviceCIDR: 10.96.0.0/12
kubeOVN:
joinCIDR: 100.64.0.0/16
loadBalancer:
type: internal
address: <control-plane-endpoint>
port: 6443
vrid: <vrid>
provider:
baremetal:
# osType: alaudaos-k
# architecture: arm64
isoImageTag: <iso-image-tag>
rootImageTag: <root-image-tag>
serviceAccountSigningKey: <base64-pem-key>
controlPlane:
replicas: 3
deployMode: normal
baremetal:
machineInventoryPool: global-control-plane-pool
computes:
- name: worker
replicas: 3
deployMode: normal
baremetal:
machineInventoryPool: global-worker-pool
在 Bare Metal 上,节点组只接受 replicas、deployMode 和 baremetal.machineInventoryPool,因为主机提供每个节点的大小、网络和磁盘。请勿设置 cpuCore、memoryGiB、network、disks、hosts 或 credentialRef。设置其中任何一项都会导致错误。
关于灾难恢复对两侧各自的值,请参阅创建 Global 集群灾难恢复对。
2. 构建安装 ISO
在 bootstrap 节点上:
<extract-dir>/res/<arch>/ac adm alpha global create --dir <install-dir> --provider baremetal
第一次运行会准备 bootstrap 集群、构建安装 ISO、打印其下载 URL 和校验和 URL,然后停止并显示错误:
The installation ISO is built. Boot every host of the global cluster from it:
download: https://<bootstrapIP>:12443/...
checksum: https://<bootstrapIP>:12443/...
...
error: the registration check did not pass, so nothing of the global cluster was applied:
- pool missing: MachineInventoryPool cpaas-system/global-control-plane-pool, which controlPlane draws from, does not exist
- pool missing: MachineInventoryPool cpaas-system/global-worker-pool, which computes[worker] draws from, does not exist
Register the hosts with the ISO and collect them into the pools, then run again:
ac adm alpha global create --dir <install-dir> --provider baremetal --reuse-manifests
Everything done so far is kept and skipped
第一次运行出现此错误是预期行为。池尚不存在,因为还没有主机注册。global 集群尚未应用任何部分。请继续执行以下步骤。在安装集群中运行所打印的命令。
下载 ISO。通过校验和 URL 对其进行验证,可以在 bootstrap 节点上验证,也可以在下载 ISO 的机器上验证。校验和文件包含 ISO 的 SHA-256 哈希值和原始文件名。原始名称包含冒号,而 Windows 不允许文件名中包含冒号。因此,保存的文件通常具有不同的名称,sha256sum -c 无法找到该文件。请改为比较哈希值:
curl -sSk <checksum-url> | awk '{print $1}' # expected hash
sha256sum <saved-iso-file> | awk '{print $1}' # actual hash
两个哈希值相同后继续。否则,重新下载 ISO。在 Windows 上,certutil -hashfile <saved-iso-file> SHA256 会打印实际哈希值。
3. 注册主机
-
从 ISO 启动每台主机。每台主机会注册为名为 global-<system-uuid> 的 MachineInventory,并报告其磁盘。随后主机会停留在 live 环境中,直到你选择其系统磁盘。你可以同时启动所有主机。如果主机在 live 环境中未获取 DHCP 地址,请按照前提条件中的准备方式配置其网络。下载 URL 会在 ISO 构建 120 分钟后过期。如果已过期,请参阅ISO 下载 URL 已过期。此 ISO 仅用于本次安装。交接后请勿重复使用。
-
在 bootstrap 节点上,列出已注册的主机以及每台等待中的主机报告的磁盘。每台主机都会等待你选择磁盘,即使主机只有一个磁盘:
<extract-dir>/res/<arch>/ac --kubeconfig /var/cpaas/data/alauda.kubeconfig \
-n cpaas-system get machineinventories.elemental.cattle.io \
-o custom-columns='NAME:.metadata.name,PHASE:.status.install.phase,IP:.metadata.labels.elemental\.cattle\.io/registration-ip'
<extract-dir>/res/<arch>/ac --kubeconfig /var/cpaas/data/alauda.kubeconfig \
-n cpaas-system get machineinventories.elemental.cattle.io <inventory-name> \
-o jsonpath='{range .status.install.candidates[*]}{.id}{"\t"}{.eligible}{"\t"}{.path}{"\t"}{.sizeBytes}{"\t"}{.reasons}{"\n"}{end}'
等待中的主机会显示 AwaitingTarget。IP 是主机用来访问 bootstrap 节点的地址,因此你可以将 inventory 与主机对应起来。每个候选行都会打印磁盘 ID、磁盘是否可选、其在 live 环境中的设备路径、以字节为单位的大小,以及无法选择该磁盘的原因(如有)。根据大小和路径识别系统磁盘。
-
在每台主机仍处于 live 环境期间,使用磁盘 ID 选择其系统磁盘:
<extract-dir>/res/<arch>/ac --kubeconfig /var/cpaas/data/alauda.kubeconfig \
-n cpaas-system annotate machineinventories.elemental.cattle.io <inventory-name> \
baremetal.alauda.io/install-target-device=<disk-id>
- 选择显示
true 的磁盘,并完全按照打印的内容使用其 ID。
- 阶段变为
Installing,主机会将 Alauda OS 安装到该磁盘并重新启动。之后无法更改该选择。
- 如果由于主机最近未被发现而导致 annotation 被拒绝,请确保主机仍在运行 ISO,然后再次运行该命令。
-
在 bootstrap 节点上再次列出已注册的主机:
<extract-dir>/res/<arch>/ac --kubeconfig /var/cpaas/data/alauda.kubeconfig \
-n cpaas-system get machineinventories.elemental.cattle.io \
-o custom-columns='NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,PHASE:.status.install.phase,PLAN:.status.plan.secretRef.name'
当 READY 为 True、PHASE 为 Installed,且 PLAN 不为 <none> 时,可以使用该主机。否则,请参阅Bare Metal 上的故障排除。
4. 创建池
为每个节点组创建一个 MachineInventoryPool。每个池必须:
- 使用
install-config.yaml 提供的名称。
- 设置
spec.clusterName: global。
- 列出至少与从该池获取主机的节点组副本数相同数量的主机。
一台主机只能属于一个池。
pools.yaml
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: MachineInventoryPool
metadata:
name: global-control-plane-pool
namespace: cpaas-system
spec:
clusterName: global
machineInventories:
- name: <inventory-1>
hostname: <hostname-1>
- name: <inventory-2>
- name: <inventory-3>
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: MachineInventoryPool
metadata:
name: global-worker-pool
namespace: cpaas-system
spec:
clusterName: global
machineInventories:
- name: <inventory-4>
- name: <inventory-5>
- name: <inventory-6>
hostname:可选。默认为 inventory 名称。
在 bootstrap 节点上:
<extract-dir>/res/<arch>/ac --kubeconfig /var/cpaas/data/alauda.kubeconfig apply -f pools.yaml
5. 安装集群
如果使用 external 负载均衡器,请在再次运行 create 前配置其转发规则。create 不会检查负载均衡器,控制平面会通过它初始化。将平台访问地址和 global VIP中在负载均衡器上转发列为是的每个端口,转发到 controlPlane.baremetal.machineInventoryPool 池中的每台主机。使用每台主机在 live 环境中获得的地址。安装完成后主机会保留该地址,即使该地址来自 DHCP。
在 bootstrap 节点上,再次运行 create,并重新使用第一次运行所渲染的清单:
<extract-dir>/res/<arch>/ac adm alpha global create --dir <install-dir> --provider baremetal --reuse-manifests
ac 首先检查 install-config.yaml 中命名的池(其成员和大小)以及 ISO URL。如果检查失败,则不会应用 global 集群的任何部分,并且错误会指出失败的项目。
安装完成后,create 返回。如果 create 停止,请再次运行相同的命令。它会跳过已经完成的工作。请参阅 create 命令。
6. 监控安装
在 bootstrap 节点上的另一个终端中:
<extract-dir>/res/<arch>/ac adm alpha global status
关于阶段和常见故障,请参阅故障排除。关于 Bare Metal 故障,请参阅Bare Metal 上的故障排除。
验证
当 create 返回时,安装即完成,但某些平台组件可能还需要几分钟才能就绪。在判断结果之前,请按照适用于 Alauda OS 的其他检查中的说明等待这些组件就绪。然后按照验证中的说明验证平台,包括其中的Alauda OS 检查。
适用于:自建 VIP(cluster.network.loadBalancer.type: internal)。使用 external 负载均衡器时跳过此检查。
以 boot 用户(ssh boot@<control-plane-node-ip>)身份登录 global 集群的控制平面节点。使用与 cluster.sshKeys 中的 SSH 公钥匹配的私钥。使用 sudo 运行 curl,因为只有 root 可以读取集群 CA 文件:
sudo curl --cacert /etc/kubernetes/pki/ca.crt https://<control-plane-vip>:6443/healthz
当其输出 ok 时继续操作。否则,请参阅Bare Metal 上的故障排除。
后续步骤
- 灾难恢复对:继续执行安装主集群和备用集群。
- 要在 Bare Metal 上创建工作负载集群,请按照为主机准备 Alauda OS和注册主机中的说明准备 OS 并注册主机,然后按照在 Bare Metal 上创建集群进行操作。
global 集群已运行 Bare Metal provider。它还已为 install-config.yaml 中的 osType 和 architecture 准备好 OS 镜像和镜像目录密钥。对于使用该 OS 和架构的主机,只需创建注册信息及其 ISO。对于使用其他架构或 OS 的主机,还需要推送镜像并添加密钥。请参阅添加镜像目录密钥。
- 要在其他基础设施上创建工作负载集群,请按照准备中的说明安装相应的 provider。