案内

  • このガイドはKubernetes v1.30を基準に作成されました。

ツールのインストール

Windowsの場合はWSL2をインストールし、Linux環境でaleを利用することをお勧めします。 こちらを参照してWSL2を先にインストールしてください。


Google Cloudアカウントの設定

gcloud CLIの初期化

1

使用するGoogleアカウントとRegion、Zoneを登録するには以下のコマンドを実行します。

gcloud init
2

プロンプトで`Sign in with a new Google Account`に該当する数値を入力してGoogleアカウントにログインします。既にログイン済みのアカウントを使用する場合は、その数値を入力します。

  Choose the account you want to use for this configuration.
  To use a federated user account, exit this command and sign in to the gcloud CLI with your login configuration file, then run this command again.

  Select an account:
    [1] Sign in with a new Google Account
    [2] Skip this step
  Please enter your numeric choice: 
3

Google Cloudはプロジェクト単位でリソースを割り当てて使用します。`Create a new project`に該当する数値を入力して新しいプロジェクトを作成できます。既に作成されたプロジェクトを使用する場合は、該当する数値を入力してください。

Pick cloud project to use:
 [1] Enter a project ID
 [2] Create a new project
Please enter numeric choice or text value (must exactly match list item):  
4

RegionおよびZoneのデフォルト値を設定するかどうかを尋ねるプロンプトで`y`を入力し、デフォルト値に設定するRegion/Zoneに該当する数値を入力してください。

Do you want to configure a default Compute Region and Zone? (Y/n)?   y

Which Google Compute Engine zone would you like to use as project default?
If you do not specify a zone via a command line flag while working with Compute Engine resources, the default is assumed.
 [1] us-east1-b
 [2] us-east1-c
 [3] us-east1-d
 [4] us-east4-c
 [5] us-east4-b
 [6] us-east4-a
 [7] us-central1-c
 [8] us-central1-a
 [9] us-central1-f
 [10] us-central1-b
 [11] us-west1-b
 [12] us-west1-c
 [13] us-west1-a
...
Did not print [75] options.
Too many options [125]. Enter "list" at prompt to print choices fully.
Please enter numeric choice or text value (must exactly match list item):

以下のように表示されれば、正常に処理されたことを示します。

...
The Google Cloud CLI is configured and ready to use!

* Commands that require authentication will use ale@example.com by default
* Commands will reference project `ale` by default
* Compute Engine commands will use region `asia-northeast3` by default
* Compute Engine commands will use zone `asia-northeast3-a` by default
...

環境変数の登録

上記で作成したプロジェクトID、Region、クラスター名、ノードの配置Zoneを環境変数として登録します。

export GCP_PROJECT_ID=<GCPプロジェクトID>
export GCP_REGION=<GCPリージョン>
export NODE_LOCATIONS=<クラスタノードの配置Zone> 
export CLUSTER_NAME=<作成するGKEクラスタ名>

アカウントとプロジェクトの設定

1

以下のコマンドを入力してGoogleアカウントにログインしてください。

gcloud auth login

自動的にブラウザが起動し、Googleアカウントログイン用のページが表示されます。ブラウザでログインを完了すると、ターミナルでログインが完了したというメッセージを確認できます。

2

次にプロジェクトを設定するため、以下のコマンドを実行します。

gcloud config set project $GCP_PROJECT_ID