4.2.3. InfraEnv リソースの作成
ベアメタル上にホステッドクラスターを作成するには、InfraEnv リソースが必要です。
4.2.3.1. InfraEnv リソースの作成とノードの追加 リンクのコピーリンクがクリップボードにコピーされました!
Hosted Control Plane では、コントロールプレーンコンポーネントは管理クラスター上の Pod として実行され、データプレーンは専用ノード上で実行されます。Assisted Service を使用すると、ハードウェアをハードウェアインベントリーに追加する検出 ISO を使用して、ハードウェアをブートできます。後でホステッドクラスターを作成するときに、インベントリーのハードウェアを使用してデータプレーンノードをプロビジョニングします。検出 ISO を取得するために使用されるオブジェクトは、InfraEnv リソースです。検出 ISO からベアメタルノードをブートするようにクラスターを設定する BareMetalHost オブジェクトを作成する必要があります。
手順
次のコマンドを入力して、ハードウェアインベントリーを保存する namespace を作成します。
$ oc --kubeconfig ~/<directory_example>/mgmt-kubeconfig create \ namespace <namespace_example>ここでは、以下のようになります。
- <directory_example>
-
管理クラスターの
kubeconfigファイルが保存されるディレクトリーの名前です。 - <namespace_example>
作成する namespace の名前 (例:
hardware-inventory) です。出力例
namespace/hardware-inventory created
次のコマンドを入力して、管理クラスターのプルシークレットをコピーします。
$ oc --kubeconfig ~/<directory_example>/mgmt-kubeconfig \ -n openshift-config get secret pull-secret -o yaml \ | grep -vE "uid|resourceVersion|creationTimestamp|namespace" \ | sed "s/openshift-config/<namespace_example>/g" \ | oc --kubeconfig ~/<directory_example>/mgmt-kubeconfig \ -n <namespace> apply -f -ここでは、以下のようになります。
- <directory_example>
-
管理クラスターの
kubeconfigファイルが保存されるディレクトリーの名前です。 - <namespace_example>
作成する namespace の名前 (例:
hardware-inventory) です。出力例
secret/pull-secret created
次のコンテンツを YAML ファイルに追加して、
InfraEnvリソースを作成します。apiVersion: agent-install.openshift.io/v1beta1 kind: InfraEnv metadata: name: hosted namespace: <namespace_example> spec: additionalNTPSources: - <ip_address> pullSecretRef: name: pull-secret sshAuthorizedKey: <ssh_public_key> # ...次のコマンドを入力して、YAML ファイルに変更を適用します。
$ oc apply -f <infraenv_config>.yaml<infraenv_config>は、ファイルの名前に置き換えます。次のコマンドを入力して、
InfraEnvリソースが作成されたことを確認します。$ oc --kubeconfig ~/<directory_example>/mgmt-kubeconfig \ -n <namespace_example> get infraenv hosted次の 2 つの方法のいずれかに従ってベアメタルホストを追加します。
Metal3 Operator を使用しない場合は、
InfraEnvリソースから検出 ISO を取得し、次のステップを実行して手動でホストをブートします。次のコマンドを入力してライブ ISO をダウンロードします。
$ oc get infraenv -A$ oc get infraenv <namespace_example> -o jsonpath='{.status.isoDownloadURL}' -n <namespace_example> <iso_url>-
ISO をブートします。ノードは Assisted Service と通信し、
InfraEnvリソースと同じ namespace にエージェントとして登録されます。 各エージェントに対して、インストールディスク ID とホスト名を設定し、承認してエージェントが使用可能であることを示します。次のコマンドを入力します。
$ oc -n <hosted_control_plane_namespace> get agents出力例
NAME CLUSTER APPROVED ROLE STAGE 86f7ac75-4fc4-4b36-8130-40fa12602218 auto-assign e57a637f-745b-496e-971d-1abbf03341ba auto-assign$ oc -n <hosted_control_plane_namespace> \ patch agent 86f7ac75-4fc4-4b36-8130-40fa12602218 \ -p '{"spec":{"installation_disk_id":"/dev/sda","approved":true,"hostname":"worker-0.example.krnl.es"}}' \ --type merge$ oc -n <hosted_control_plane_namespace> \ patch agent 23d0c614-2caa-43f5-b7d3-0b3564688baa -p \ '{"spec":{"installation_disk_id":"/dev/sda","approved":true,"hostname":"worker-1.example.krnl.es"}}' \ --type merge$ oc -n <hosted_control_plane_namespace> get agents出力例
NAME CLUSTER APPROVED ROLE STAGE 86f7ac75-4fc4-4b36-8130-40fa12602218 true auto-assign e57a637f-745b-496e-971d-1abbf03341ba true auto-assign
Metal3 Operator を使用する場合は、次のオブジェクトを作成することで、ベアメタルホストの登録を自動化できます。
YAML ファイルを作成し、そこに次のコンテンツを追加します。
apiVersion: v1 kind: Secret metadata: name: hosted-worker0-bmc-secret namespace: <namespace_example> data: password: <password> username: <username> type: Opaque --- apiVersion: v1 kind: Secret metadata: name: hosted-worker1-bmc-secret namespace: <namespace_example> data: password: <password> username: <username> type: Opaque --- apiVersion: v1 kind: Secret metadata: name: hosted-worker2-bmc-secret namespace: <namespace_example> data: password: <password> username: <username> type: Opaque --- apiVersion: metal3.io/v1alpha1 kind: BareMetalHost metadata: name: hosted-worker0 namespace: <namespace_example> labels: infraenvs.agent-install.openshift.io: hosted annotations: inspect.metal3.io: disabled bmac.agent-install.openshift.io/hostname: hosted-worker0 spec: automatedCleaningMode: disabled bmc: disableCertificateVerification: True address: <bmc_address> credentialsName: hosted-worker0-bmc-secret bootMACAddress: aa:aa:aa:aa:02:01 online: true --- apiVersion: metal3.io/v1alpha1 kind: BareMetalHost metadata: name: hosted-worker1 namespace: <namespace_example> labels: infraenvs.agent-install.openshift.io: hosted annotations: inspect.metal3.io: disabled bmac.agent-install.openshift.io/hostname: hosted-worker1 spec: automatedCleaningMode: disabled bmc: disableCertificateVerification: True address: <bmc_address> credentialsName: hosted-worker1-bmc-secret bootMACAddress: aa:aa:aa:aa:02:02 online: true --- apiVersion: metal3.io/v1alpha1 kind: BareMetalHost metadata: name: hosted-worker2 namespace: <namespace_example> labels: infraenvs.agent-install.openshift.io: hosted annotations: inspect.metal3.io: disabled bmac.agent-install.openshift.io/hostname: hosted-worker2 spec: automatedCleaningMode: disabled bmc: disableCertificateVerification: True address: <bmc_address> credentialsName: hosted-worker2-bmc-secret bootMACAddress: aa:aa:aa:aa:02:03 online: true --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: capi-provider-role namespace: <namespace_example> rules: - apiGroups: - agent-install.openshift.io resources: - agents verbs: - '*'ここでは、以下のようになります。
- <namespace_example>
- namespace です。
- <password>
- シークレットのパスワードです。
- <username>
- シークレットのユーザー名です。
- <bmc_address>
BareMetalHostオブジェクトの BMC アドレスです。注記この YAML ファイルを適用すると、次のオブジェクトが作成されます。
- ベースボード管理コントローラー (BMC) の認証情報が含まれるシークレット
-
BareMetalHostオブジェクト - HyperShift Operator によるエージェントの管理が可能になるロール
BareMetalHostオブジェクトでinfraenvs.agent-install.openshift.io: hostedカスタムラベルを使用してInfraEnvリソースが参照されることに注意してください。これにより、生成された ISO を使用してノードがブートされます。
次のコマンドを入力して、YAML ファイルに変更を適用します。
$ oc apply -f <bare_metal_host_config>.yaml<bare_metal_host_config>は、ファイルの名前に置き換えます。
次のコマンドを入力し、
BareMetalHostオブジェクトの状態がProvisioningになるまで数分間待ちます。$ oc --kubeconfig ~/<directory_example>/mgmt-kubeconfig -n <namespace_example> get bmh出力例
NAME STATE CONSUMER ONLINE ERROR AGE hosted-worker0 provisioning true 106s hosted-worker1 provisioning true 106s hosted-worker2 provisioning true 106s次のコマンドを入力して、ノードが起動し、エージェントとして表示されていることを確認します。このプロセスには数分かかる場合があり、コマンドを複数回入力する必要があることもあります。
$ oc --kubeconfig ~/<directory_example>/mgmt-kubeconfig -n <namespace_example> get agent出力例
NAME CLUSTER APPROVED ROLE STAGE aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa0201 true auto-assign aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa0202 true auto-assign aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa0203 true auto-assign