13.2. API를 사용하여 Nutanix에 호스트 추가
API를 사용하여 Nutanix에 호스트를 추가하려면 지원 설치 관리자에서 검색 이미지 ISO를 생성합니다. 최소 검색 이미지 ISO를 사용합니다. 이 설정은 기본 설정입니다. 이미지에는 네트워킹으로 호스트를 부팅하는 데 필요한 항목만 포함됩니다. 대부분의 콘텐츠는 부팅 시 다운로드됩니다. ISO 이미지의 크기는 약 100MB입니다.
이 작업이 완료되면 Nutanix 플랫폼에 대한 이미지를 생성하고 Nutanix 가상 머신을 생성해야 합니다.
사전 요구 사항
- 지원 설치 관리자 API 인증을 설정했습니다.
- 지원 설치 관리자 클러스터 프로필이 생성되어 있습니다.
- 지원 설치 관리자 인프라 환경이 생성되어 있습니다.
-
쉘에서
$INFRA_ENV_ID
로 내보낸 인프라 환경 ID가 있어야 합니다. - 지원 설치 관리자 클러스터 구성을 완료했습니다.
- Nutanix 클러스터 환경을 설정하고 클러스터 이름과 서브넷 이름을 적어 둡니다.
절차
- ignition 파일로 부팅하려면 검색 이미지를 구성합니다.
환경 변수를 저장할 Nutanix 클러스터 구성 파일을 생성합니다.
$ touch ~/nutanix-cluster-env.sh
$ chmod +x ~/nutanix-cluster-env.sh
새 터미널 세션을 시작해야 하는 경우 환경 변수를 쉽게 다시 로드할 수 있습니다. 예를 들면 다음과 같습니다.
$ source ~/nutanix-cluster-env.sh
구성 파일의 NTX_CLUSTER_NAME 환경 변수에 Nutanix 클러스터의 이름을
NTX_CLUSTER_NAME
에 할당합니다.$ cat << EOF >> ~/nutanix-cluster-env.sh export NTX_CLUSTER_NAME=<cluster_name> EOF
&
lt;cluster_name
>을 Nutanix 클러스터 이름으로 바꿉니다.구성 파일의
NTX_SUBNET_NAME
환경 변수에 Nutanix 클러스터의 서브넷 이름을 할당합니다.$ cat << EOF >> ~/nutanix-cluster-env.sh export NTX_SUBNET_NAME=<subnet_name> EOF
&
lt;subnet_name
>을 Nutanix 클러스터 서브넷 이름으로 바꿉니다.API 토큰을 새로 고칩니다.
$ source refresh-token
다운로드 URL을 가져옵니다.
$ curl -H "Authorization: Bearer ${API_TOKEN}" \ https://api.openshift.com/api/assisted-install/v2/infra-envs/${INFRA_ENV_ID}/downloads/image-url
Nutanix 이미지 구성 파일을 생성합니다.
$ cat << EOF > create-image.json { "spec": { "name": "ocp_ai_discovery_image.iso", "description": "ocp_ai_discovery_image.iso", "resources": { "architecture": "X86_64", "image_type": "ISO_IMAGE", "source_uri": "<image_url>", "source_options": { "allow_insecure_connection": true } } }, "metadata": { "spec_version": 3, "kind": "image" } } EOF
&
lt;image_url&
gt;을 이전 단계에서 다운로드한 이미지 URL로 바꿉니다.Nutanix 이미지를 생성합니다.
$ curl -k -u <user>:'<password>' -X 'POST' \ 'https://<domain-or-ip>:<port>/api/nutanix/v3/images \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d @./create-image.json | jq '.metadata.uuid'
<
;user&
gt;를 Nutanix 사용자 이름으로 바꿉니다.'<password>'
를 Nutanix 암호로 바꿉니다. <domain-or-ip
>를 Nutanix underform의 도메인 이름 또는 IP 주소로 바꿉니다. <port&
gt;를 Nutanix 서버의 포트로 바꿉니다. 포트 기본값은9440
입니다.반환된 UUID를 구성 파일의
NTX_IMAGE_UUID
환경 변수에 할당합니다.$ cat << EOF >> ~/nutanix-cluster-env.sh export NTX_IMAGE_UUID=<uuid> EOF
Nutanix 클러스터 UUID를 가져옵니다.
$ curl -k -u <user>:'<password>' -X 'POST' \ 'https://<domain-or-ip>:<port>/api/nutanix/v3/clusters/list' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "kind": "cluster" }' | jq '.entities[] | select(.spec.name=="<nutanix_cluster_name>") | .metadata.uuid'
<
;user&
gt;를 Nutanix 사용자 이름으로 바꿉니다.'<password>'
를 Nutanix 암호로 바꿉니다. <domain-or-ip
>를 Nutanix underform의 도메인 이름 또는 IP 주소로 바꿉니다. <port&
gt;를 Nutanix 서버의 포트로 바꿉니다. 포트 기본값은9440
입니다. <nutanix_cluster_name&
gt;을 Nutanix 클러스터 이름으로 바꿉니다.반환된 Nutanix 클러스터 UUID를 구성 파일의
NTX_CLUSTER_UUID
환경 변수에 할당합니다.$ cat << EOF >> ~/nutanix-cluster-env.sh export NTX_CLUSTER_UUID=<uuid> EOF
&
lt;uuid&
gt;를 Nutanix 클러스터의 반환된 UUID로 바꿉니다.Nutanix 클러스터의 서브넷 UUID를 가져옵니다.
$ curl -k -u <user>:'<password>' -X 'POST' \ 'https://<domain-or-ip>:<port>/api/nutanix/v3/subnets/list' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "kind": "subnet", "filter": "name==<subnet_name>" }' | jq '.entities[].metadata.uuid'
<
;user&
gt;를 Nutanix 사용자 이름으로 바꿉니다.'<password>'
를 Nutanix 암호로 바꿉니다. <domain-or-ip
>를 Nutanix underform의 도메인 이름 또는 IP 주소로 바꿉니다. <port&
gt;를 Nutanix 서버의 포트로 바꿉니다. 포트 기본값은9440
입니다. <subnet_name
>을 클러스터 서브넷 이름으로 바꿉니다.반환된 Nutanix 서브넷 UUID를 구성 파일의
NTX_CLUSTER_UUID
환경 변수에 할당합니다.$ cat << EOF >> ~/nutanix-cluster-env.sh export NTX_SUBNET_UUID=<uuid> EOF
&
lt;uuid&
gt;를 클러스터 서브넷의 반환된 UUID로 바꿉니다.Nutanix 환경 변수가 설정되어 있는지 확인합니다.
$ source ~/nutanix-cluster-env.sh
각 Nutanix 호스트에 대한 VM 구성 파일을 생성합니다. 컨트롤 플레인 (마스터) VM과 두 개 이상의 작업자 VM을 생성합니다. 예를 들면 다음과 같습니다.
$ touch create-master-0.json
$ cat << EOF > create-master-0.json { "spec": { "name": "<host_name>", "resources": { "power_state": "ON", "num_vcpus_per_socket": 1, "num_sockets": 16, "memory_size_mib": 32768, "disk_list": [ { "disk_size_mib": 122880, "device_properties": { "device_type": "DISK" } }, { "device_properties": { "device_type": "CDROM" }, "data_source_reference": { "kind": "image", "uuid": "$NTX_IMAGE_UUID" } } ], "nic_list": [ { "nic_type": "NORMAL_NIC", "is_connected": true, "ip_endpoint_list": [ { "ip_type": "DHCP" } ], "subnet_reference": { "kind": "subnet", "name": "$NTX_SUBNET_NAME", "uuid": "$NTX_SUBNET_UUID" } } ], "guest_tools": { "nutanix_guest_tools": { "state": "ENABLED", "iso_mount_state": "MOUNTED" } } }, "cluster_reference": { "kind": "cluster", "name": "$NTX_CLUSTER_NAME", "uuid": "$NTX_CLUSTER_UUID" } }, "api_version": "3.1.0", "metadata": { "kind": "vm" } } EOF
&
lt;host_name
>을 호스트 이름으로 바꿉니다.각 Nutanix 가상 머신을 부팅합니다.
$ curl -k -u <user>:'<password>' -X 'POST' \ 'https://<domain-or-ip>:<port>/api/nutanix/v3/vms' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d @./<vm_config_file_name> | jq '.metadata.uuid'
<
;user&
gt;를 Nutanix 사용자 이름으로 바꿉니다.'<password>'
를 Nutanix 암호로 바꿉니다. <domain-or-ip
>를 Nutanix underform의 도메인 이름 또는 IP 주소로 바꿉니다. <port&
gt;를 Nutanix 서버의 포트로 바꿉니다. 포트 기본값은9440
입니다. <vm_config_file_name&
gt;을 VM 구성 파일의 이름으로 바꿉니다.반환된 VM UUID를 구성 파일의 고유한 환경 변수에 할당합니다.
$ cat << EOF >> ~/nutanix-cluster-env.sh export NTX_MASTER_0_UUID=<uuid> EOF
&
lt;uuid&
gt;를 VM의 반환된 UUID로 바꿉니다.참고환경 변수에는 각 VM마다 고유한 이름이 있어야 합니다.
지원 설치 프로그램이 각 VM을 검색하고 검증을 통과할 때까지 기다립니다.
$ 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 '.enabled_host_count'
Nutanix와의 통합을 활성화하도록 클러스터 정의를 수정합니다.
$ curl https://api.openshift.com/api/assisted-install/v2/clusters/${CLUSTER_ID} \ -X PATCH \ -H "Authorization: Bearer ${API_TOKEN}" \ -H "Content-Type: application/json" \ -d ' { "platform_type":"nutanix" } ' | jq
- 설치 절차를 계속합니다.