This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.第 4 章 修改机器集
您可以对机器集进行更改,例如添加标签、更改实例类型或更改块存储。
在 Red Hat Virtualization(RHV) 中,您还可以更改机器集,以便在不同的存储域中置备新节点。
如果您需要在不进行其他更改的情况下扩展机器集,请参阅手动扩展机器集。
4.1. 使用 CLI 修改机器集 复制链接链接已复制到粘贴板!
修改机器集时,您的更改只适用于保存更新的 MachineSet
自定义资源 (CR) 后创建的机器。更改不会影响现有的机器。您可以通过扩展机器集来将现有机器替换为反映更新的配置的新机器。
如果您需要在不进行其他更改的情况下扩展机器集,则不需要删除机器。
默认情况下,OpenShift Container Platform 路由器 Pod 部署到机器上。由于路由器需要访问某些集群资源(包括 Web 控制台),除非先重新放置了路由器 Pod,否则请不要将机器集扩展为 0
。
先决条件
- OpenShift Container Platform 集群使用 Machine API。
-
以管理员身份使用 OpenShift CLI (
oc
) 登录集群。
流程
编辑机器集:
oc edit machineset <machine_set_name> -n openshift-machine-api
$ oc edit machineset <machine_set_name> -n openshift-machine-api
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 请注意
spec.replicas
字段的值,因为在扩展机器集以应用更改时需要它。Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 此流程中的示例显示具有
replicas
值2
的机器集。
- 使用您想要的配置选项来更新机器设置 CR,并保存您的更改。
运行以下命令,列出由更新的机器集管理的机器:
oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
$ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
NAME PHASE TYPE REGION ZONE AGE <machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h <machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h
NAME PHASE TYPE REGION ZONE AGE <machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h <machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 对于由更新的机器集管理的每台机器,请运行以下命令设置
delete
注解:oc annotate machine/<machine_name_original_1> \ -n openshift-machine-api \ machine.openshift.io/delete-machine="true"
$ oc annotate machine/<machine_name_original_1> \ -n openshift-machine-api \ machine.openshift.io/delete-machine="true"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 运行以下命令,将机器设置为两倍的副本数:
oc scale --replicas=4 \ machineset <machine_set_name> \ -n openshift-machine-api
$ oc scale --replicas=4 \
1 machineset <machine_set_name> \ -n openshift-machine-api
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 原始示例值
2
加倍到4
。
运行以下命令,列出由更新的机器集管理的机器:
oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
$ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
NAME PHASE TYPE REGION ZONE AGE <machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h <machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h <machine_name_updated_1> Provisioned m6i.xlarge us-west-1 us-west-1a 55s <machine_name_updated_2> Provisioning m6i.xlarge us-west-1 us-west-1a 55s
NAME PHASE TYPE REGION ZONE AGE <machine_name_original_1> Running m6i.xlarge us-west-1 us-west-1a 4h <machine_name_original_2> Running m6i.xlarge us-west-1 us-west-1a 4h <machine_name_updated_1> Provisioned m6i.xlarge us-west-1 us-west-1a 55s <machine_name_updated_2> Provisioning m6i.xlarge us-west-1 us-west-1a 55s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 当新机器处于
Running
阶段时,您可以将机器设置为原始副本数。运行以下命令,将机器设置为原始副本数:
oc scale --replicas=2 \ machineset <machine_set_name> \ -n openshift-machine-api
$ oc scale --replicas=2 \
1 machineset <machine_set_name> \ -n openshift-machine-api
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 原始示例值
2
。
验证
要验证没有更新的配置的机器,请运行以下命令列出由更新的计算机器集管理的机器:
oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
$ oc get -n openshift-machine-api machines -l machine.openshift.io/cluster-api-machineset=<machine_set_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 删除过程中的输出示例
NAME PHASE TYPE REGION ZONE AGE <machine_name_original_1> Deleting m6i.xlarge us-west-1 us-west-1a 4h <machine_name_original_2> Deleting m6i.xlarge us-west-1 us-west-1a 4h <machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 5m41s <machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 5m41s
NAME PHASE TYPE REGION ZONE AGE <machine_name_original_1> Deleting m6i.xlarge us-west-1 us-west-1a 4h <machine_name_original_2> Deleting m6i.xlarge us-west-1 us-west-1a 4h <machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 5m41s <machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 5m41s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 删除完成后的输出示例
NAME PHASE TYPE REGION ZONE AGE <machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 6m30s <machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 6m30s
NAME PHASE TYPE REGION ZONE AGE <machine_name_updated_1> Running m6i.xlarge us-west-1 us-west-1a 6m30s <machine_name_updated_2> Running m6i.xlarge us-west-1 us-west-1a 6m30s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 要验证更新机器集创建的机器是否具有正确的配置,请运行以下命令检查 CR 中的相关字段是否有新机器:
oc describe machine <machine_name_updated_1> -n openshift-machine-api
$ oc describe machine <machine_name_updated_1> -n openshift-machine-api
Copy to Clipboard Copied! Toggle word wrap Toggle overflow