0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ARO を terraformで作成する

Last updated at Posted at 2025-06-05

1. はじめに

Red Hat の Technical Salesチームが公開している Terraform のスクリプトを試して見ます。
尚、このスクリプトは、販売活動の中で作成したり、社内で使用しているスクリプトを公開しているものなので、サポート等はありません。あくまで「サンプル」として公開しているものなので、ご注意下さい。

2. terraform のプロジェクトは以下の2つのプロジェクトからできてます。

以下の Repository をダウンロードして下さい。

git clone https://github.com/rh-mobb/terraform-aro

尚、以下の Repository は、上記の terraform の中で、Service Provider を作成する module の定義としてiam.tf 内で参照されています。terraform init 時に内部で呼び出されて .terraform 配下に自動で clone されるので、個別に clone をする必要はありませんが、読んでおくと理解が深まる事が書いてあるので参考までに置いておきます。

3. 事前準備

Terraform では、export TF_VAR_<変数名> でファイル内で使われている変数を、シェル環境変数で設定/上書きできます。以下の設定をしておきます。

Azure の Subscription ID を Export しておきます。

export TF_VAR_subscription_id=<Azure の Subscription ID>

ダウンロードした ARO Cluster を作成するための Pull Secret のパスを Export しておきます。

export TF_VAR_pull_secret_path=<pull secret の file n>

クラスタの作成場所はデフォルトは eastus になっているので、日本に変更しておきます。

export TF_VAR_location=japaneast

クラスターの名前を指定しておきます(デフォルトは my-aro-cluster)

export TF_VAR_cluster_name=my_cluster

ARO Cluster を作成する Resource Group 名を指定しておきます。(デフォルトは <cluster名>-rg )

export TF_VAR_resource_group_name=yhanada_rg

これらの変数は、variables.tf の中に定義されているので、デフォルトを書き替えたい場合は、ファイルを直接編集します。

この記事の設定では、AROの最少構成である Controleplane node x 3本、Worker Node x 3本の構成が 東日本リージョンに作成されます。この記事作成時点の ARO の最少 Worker Node数は 3本です。(通常の self-managed OpenShift / ROSA は、2本が最少構成)

4. クラスターの作成

git clone したディレクトリに移動して初期化します。

terraform init

プランを作成します。

terraform plan --out aro.plan

以下でクラスターの作成が開始されます。デフォルトでは 3本の Master Node と 3本の Worker Node を持ったクラスターが作成されます。

terraform apply aro.plan

暫くすると以下のように完了画面が出ます。

...
azurerm_redhat_openshift_cluster.cluster: Still creating... [49m20s elapsed]
azurerm_redhat_openshift_cluster.cluster: Still creating... [49m30s elapsed]
azurerm_redhat_openshift_cluster.cluster: Still creating... [49m40s elapsed]
azurerm_redhat_openshift_cluster.cluster: Creation complete after 49m42s [id=/subscriptions/4f696bb9-2a04-4131-9920-b9f7aca70567/resourceGroups/my-aro-cluster-rg/providers/Microsoft.RedHatOpenShift/openShiftClusters/my-aro-cluster]

Apply complete! Resources: 36 added, 0 changed, 0 destroyed.

Outputs:

api_server_ip = "48.111.222.30"
api_url = "https://api.luabcd123.japaneast.aroapp.io:6443/"
console_url = "https://console-openshift-console.apps.lukvxfge.japaneast.aroapp.io/"
ingress_ip = "74.111.54.5"
$

ARO Cluster のパスワードを環境変数にセットします。

ARO_PASS=$(az aro list-credentials --name ${TF_VAR_cluster_name} \
  --resource-group ${TF_VAR_cluster_name}-rg  -o tsv --query kubeadminPassword)

ログインします。

oc login $(terraform output -raw api_url) \
    --username kubeadmin --password "${ARO_PASS}"

試しに何かコマンドを打ってみましょう。oc get nodeで Node 構成を確認してみます。

$ oc get nodes
NAME                                       STATUS   ROLES                  AGE   VERSION
my-cluster-6vfwt-master-0                  Ready    control-plane,master   54m   v1.29.10+67d3387
my-cluster-6vfwt-master-1                  Ready    control-plane,master   55m   v1.29.10+67d3387
my-cluster-6vfwt-master-2                  Ready    control-plane,master   54m   v1.29.10+67d3387
my-cluster-6vfwt-worker-japaneast1-nm7gh   Ready    worker                 47m   v1.29.10+67d3387
my-cluster-6vfwt-worker-japaneast2-rlvxc   Ready    worker                 49m   v1.29.10+67d3387
my-cluster-6vfwt-worker-japaneast3-l8js5   Ready    worker                 48m   v1.29.10+67d3387
$

5. クラスターの削除

クラスターとクラスター作製のために作製した Azure のリソース (Network や Resource Group) を以下のコマンドで削除できます。

terraform destroy
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?