9.2. 使用 API 选择一个角色
您可以使用 /v2/infra-envs/{infra_env_id}/hosts/{host_id} 端点为主机选择一个角色。主机可以是两个角色之一:
-
Master :具有
角色的主机将作为 control plane 主机运行。master -
Worker :具有
worker角色的主机将作为worker主机运行。
默认情况下,辅助安装程序将主机设置为 auto-assign,这意味着安装程序将确定主机是否是 master 角色还是 worker 角色。使用这个流程设置主机的角色。
先决条件
- 您已将主机添加到集群中。
流程
刷新 API 令牌:
$ source refresh-token
获取主机 ID:
$ curl -s -X GET "https://api.openshift.com/api/assisted-install/v2/clusters/$CLUSTER_ID" \ --header "Content-Type: application/json" \ -H "Authorization: Bearer $API_TOKEN" \ | jq '.host_networks[].host_ids'
输出示例
[ "1062663e-7989-8b2d-7fbb-e6f4d5bb28e5" ]
修改
host_role设置:$ curl https://api.openshift.com/api/assisted-install/v2/infra-envs/${INFRA_ENV_ID}/hosts/<host_id> \ -X PATCH \ -H "Authorization: Bearer ${API_TOKEN}" \ -H "Content-Type: application/json" \ -d ' { "host_role":"worker" } ' | jq将
<host_id> 替换为主机的 ID。