このドキュメントでは、Anthos clusters on VMware(GKE On-Prem)のさまざまな部分に対して、別々の Google Cloud プロジェクトを使用する方法について説明します。
ここでは手順全体を詳しく解説します。Google Cloud プロジェクトの使用についての簡単な説明については、Google Cloud プロジェクト(クイックスタート)をご覧ください。
準備
クラスタ構成ファイル
管理クラスタとユーザー クラスタの構成ファイルには、Google Cloud プロジェクト ID を指定できるフィールドがいくつかあります。
stackdriver: projectID: "" ... gkeConnect: projectID: "" ... usageMetering: bigQueryProjectID: "" ... cloudAuditLogging: projectID: ""
これには、あるプロジェクトでは Google Cloud コンソールからクラスタを管理し、別のプロジェクトではログと指標などを確認するということが可能になる、という意図があります。1 つの例外として、監査ロギング プロジェクトは、接続プロジェクトと同じである必要があります。
異なるプロジェクト ID を使用する必要はありません。たとえば、管理とロギングの両方に同じプロジェクトを使用できます。必要な場合には、すべてに同じプロジェクトを使用することもできます。
Google Cloud プロジェクトにおけるサービスの有効化
各 Google Cloud プロジェクトでは、特定のサービスを有効にする必要があります。たとえば、接続プロジェクトでは、次のサービスを有効にする必要があります。
cloudresourcemanager.googleapis.com container.googleapis.com gkeconnect.googleapis.com gkehub.googleapis.com serviceusage.googleapis.com iam.googleapis.com
プロジェクトでサービスを有効にするには、Google Cloud プロジェクトに対する特定の権限が必要です。詳しくは、アクセス制御の services.enable
に必要な権限をご覧ください。
必要な権限を持っている場合は、自分でサービスを有効にできます。権限を持っていない場合は、組織内の他のユーザーがサービスを有効にする必要があります。
接続プロジェクト
ユーザー クラスタを作成すると、Anthos clusters on VMware は Connect を使用して、任意の Google Cloud プロジェクトにクラスタを登録します。クラスタの登録が完了したら、Google Cloud コンソールでこのプロジェクトを表示および管理できます。
Connect は Connect Agent という Deployment を使用して、ユーザー クラスタと Google Cloud プロジェクトの間の接続を確立します。
ユーザー クラスタ構成ファイルで、クラスタを表示および管理する Google Cloud プロジェクトの ID に、gkecConnect.projectID
を設定します。
接続プロジェクトで API を有効にする
接続プロジェクトで必要な API を有効にするには:
Linux / macOS
gcloud services enable --project [PROJECT_ID] \ cloudresourcemanager.googleapis.com \ container.googleapis.com \ gkeconnect.googleapis.com \ gkehub.googleapis.com \ serviceusage.googleapis.com \ iam.googleapis.com
ここで、[PROJECT_ID] は接続プロジェクトの ID です。
Windows
gcloud services enable --project [PROJECT_ID] ^ cloudresourcemanager.googleapis.com ^ container.googleapis.com ^ gkeconnect.googleapis.com ^ gkehub.googleapis.com ^ serviceusage.googleapis.com ^ iam.googleapis.com ^ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] は接続プロジェクトの ID です。
接続プロジェクトのサービス アカウントにロールを付与する
接続登録サービス アカウントと接続エージェント サービス アカウントには、接続プロジェクトに対する特定のロールを付与する必要があります。
詳細については、接続登録サービス アカウントと接続エージェント サービス アカウントをご覧ください。
logging-monitoring プロジェクト
ユーザー クラスタでは、ロギングと指標エージェントがデータを収集し、Cloud Logging と Cloud Monitoring で使用できるようにします。クラスタからログと指標を表示するには、関連する Google Cloud プロジェクトを指定する必要があります。
ユーザー クラスタ構成ファイルで、ロギングとモニタリングに関連付ける Google Cloud プロジェクトの ID に、stackdriver.projectID
を設定します。これは、クラスタのログと指標を表示するプロジェクトです。
logging-monitoring プロジェクトで API を有効にする
ロギングモニタリング プロジェクトで必要な API を有効にするには:
Linux / macOS
gcloud services enable --project [PROJECT_ID] \ stackdriver.googleapis.com \ monitoring.googleapis.com \ logging.googleapis.com \ serviceusage.googleapis.com \ iam.googleapis.com \ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] は logging-monitoring プロジェクトの ID です。
Windows
gcloud services enable --project [PROJECT_ID] ^ stackdriver.googleapis.com ^ monitoring.googleapis.com ^ logging.googleapis.com ^ serviceusage.googleapis.com ^ iam.googleapis.com ^ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] は logging-monitoring プロジェクトの ID です。
logging-monitoring プロジェクトのサービス アカウントにロールを付与する
logging-monitoring サービス アカウントには、logging-monitoring プロジェクトに対する特定のロールが付与されている必要があります。
詳細については、logging-monitoring サービス アカウントをご覧ください。
監査ロギング プロジェクト
クラスタで Cloud Audit Logs を有効にすると、クラスタの Kubernetes API サーバーからの監査ログエントリが Google Cloud に送信されます。
監査ログを表示するプロジェクトは、監査ロギング プロジェクトと呼ばれます。監査ロギング プロジェクトは、接続プロジェクトと同じである必要があります。
クラスタ構成ファイルで、接続プロジェクトの ID に cloudAuditLogging.projectID
を設定します。
監査ロギング プロジェクトで API を有効にする
監査ロギング プロジェクトで必要な API を有効にするには:
Linux / macOS
gcloud services enable --project [PROJECT_ID] \ anthosgke.googleapis.com \ anthosaudit.googleapis.com \ serviceusage.googleapis.com \ iam.googleapis.com \ cloudresourcemanager.googleapis.com
[PROJECT_ID] は、監査ロギング プロジェクトの ID です。
Windows
gcloud services enable --project [PROJECT_ID] ^ anthosgke.googleapis.com ^ anthosaudit.googleapis.com ^ serviceusage.googleapis.com ^ iam.googleapis.com ^ cloudresourcemanager.googleapis.com
[PROJECT_ID] は、監査ロギング プロジェクトの ID です。
監査ロギング プロジェクトのサービス アカウントにロールを付与する
監査ロギング サービス アカウントには、監査ロギング プロジェクトに対する特定のロールが付与されている必要があります。
詳しくは、監査ロギング サービス アカウントをご覧ください。
コンポーネント アクセス サービス アカウントの親プロジェクト
クラスタを作成するためには、Anthos clusters on VMware が Container Registry からコンポーネントをダウンロードするために使用できるサービス アカウントが必要です。このサービス アカウントは、コンポーネント アクセス サービス アカウントと呼ばれます。
コンポーネント アクセス サービス アカウントを作成した Google Cloud プロジェクトは、コンポーネント アクセス サービス アカウントの親と呼ばれます。このプロジェクトは、クラスタ構成ファイルで指定したプロジェクトの 1 つと同じプロジェクトにできます。もしくは、構成ファイルで指定したすべてのプロジェクトと異なったものにすることもできます。サービス アカウントと親プロジェクトの詳細については、サービス アカウントと Google Cloud プロジェクトについてをご覧ください。
コンポーネント アクセス サービス アカウントの親プロジェクトで必要な API を有効にするには:
Linux / macOS
gcloud services enable --project [PROJECT_ID] \ serviceusage.googleapis.com \ iam.googleapis.com \ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] はコンポーネント アクセス サービス アカウントの親プロジェクトの ID です。
Windows
gcloud services enable --project [PROJECT_ID] ^ serviceusage.googleapis.com ^ iam.googleapis.com ^ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] はコンポーネント アクセス サービス アカウントの親プロジェクトの ID です。
使用状況測定プロジェクト
ユーザー クラスタで GKE 使用状況測定を有効にすると、Anthos clusters on VMware は、任意の Google Cloud プロジェクトに関連付けられている BigQuery データセットに使用状況データを保存します。
ユーザー クラスタ構成ファイルで、使用状況データを保存する Google Cloud プロジェクトの ID に usageMetering.bigQueryProjectID
を設定します。
使用状況測定プロジェクトで API を有効にする
使用状況測定プロジェクトで必要な API を有効にするには:
Linux / macOS
gcloud services enable --project [PROJECT_ID] \ bigquery.googleapis.com \ serviceusage.googleapis.com \ iam.googleapis.com \ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] は、使用状況測定プロジェクトの ID です。
Windows
gcloud services enable --project [PROJECT_ID] ^ bigquery.googleapis.com ^ serviceusage.googleapis.com ^ iam.googleapis.com ^ cloudresourcemanager.googleapis.com
ここで、[PROJECT_ID] は、使用状況測定プロジェクトの ID です。
使用状況測定プロジェクトのサービス アカウントにロールを付与する
使用状況測定サービス アカウントには、使用状況測定プロジェクトに対する特定のロールが付与されている必要があります。
詳しくは、使用状況測定サービス アカウントをご覧ください。