複数の Google Cloud プロジェクトの使用

このページでは、GKE On-Prem のさまざまな部分に応じて、異なる Google Cloud プロジェクトを使い分ける方法を説明します。

クラスタ構成ファイルには、Google Cloud プロジェクト ID を指定できる複数のフィールドがあります。

...
usercluster:
  usagemetering:
    bigqueryprojectid: ""
...
gkeconnect:
  projectid: ""
...
stackdriver:
  projectid: ""
...
cloudauditlogging:
  projectid: ""

すなわち、GKE On-Prem に接続するためのプロジェクトとロギングとモニタリングのためのプロジェクトなどといったように、複数のプロジェクトを持つことができます。

異なるプロジェクト ID を使用する必要はありません。たとえば、接続とロギングの両方に同じプロジェクトを使用できます。必要な場合には、すべてに同じプロジェクトを使用することもできます。

使用状況測定プロジェクト

ユーザー クラスタで GKE 使用状況測定を有効にすると、GKE On-Prem は選択した Cloud プロジェクトに関連付けられた BigQuery データセットに使用状況データを保存します。

GKE On-Prem 構成ファイルで、usercluster.usagemetering.bigqueryprojectid を使用量データを格納する Cloud プロジェクトの ID に設定します。

使用状況測定プロジェクトで 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 です。

使用状況測定プロジェクトのサービス アカウントにロールを付与する

使用状況測定サービス アカウントには、使用状況測定プロジェクトに対する特定のロールが付与されている必要があります。

詳しくは、使用状況測定サービス アカウントをご覧ください。

接続プロジェクト

ユーザー クラスタを作成すると、GKE On-Prem は Connect を使用して任意の Cloud プロジェクトでクラスタを登録します。クラスタの登録が完了したら、Google Cloud Console でこのプロジェクトを表示および管理できます。

Connect は、Connect Agent と呼ばれる Deployment を使用して、GKE On-Prem クラスタと Cloud プロジェクト間の接続を確立します。

GKE On-Prem 構成ファイルで、クラスタの表示と管理を行う Cloud プロジェクトの ID に gkeconnect.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 \
    cloudresourcemanager.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 で使用できるようにします。クラスタからログと指標を表示するには、関連する Cloud プロジェクトを指定する必要があります。

ユーザー クラスタ構成ファイルで、ロギングとモニタリングに関連付ける 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 サービス アカウントをご覧ください。

監査ロギング プロジェクト

GKE On-Prem の Cloud Audit Logs を有効にすると、クラスタの Kubernetes API サーバーからの監査ログエントリが Google Cloud に送信されます。監査ログエントリは、任意の Cloud プロジェクトで表示できます。

GKE On-Prem 構成ファイルで、cloudauditlogging.projectid を監査ログを表示する Cloud プロジェクトの ID に設定します。

監査ロギング プロジェクトで API を有効にする

監査ロギング プロジェクトで必要な API を有効にするには:

Linux / macOS

gcloud services enable --project [PROJECT_ID] \
    anthosgke.googleapis.com \
    serviceusage.googleapis.com \
    iam.googleapis.com \
    cloudresourcemanager.googleapis.com

[PROJECT_ID] は、監査ロギング プロジェクトの ID です。

Windows

gcloud services enable --project [PROJECT_ID] ^
    anthosgke.googleapis.com ^
    serviceusage.googleapis.com ^
    iam.googleapis.com ^
    cloudresourcemanager.googleapis.com

[PROJECT_ID] は、監査ロギング プロジェクトの ID です。

監査ロギング プロジェクトのサービス アカウントにロールを付与する

監査ロギング サービス アカウントには、監査ロギング プロジェクトに対する特定のロールが付与されている必要があります。

詳しくは、監査ロギング サービス アカウントをご覧ください。

コンポーネント アクセス サービス アカウントの親プロジェクト

GKE On-Prem をインストールするには、次の操作を完了していることが必要です。

  • Cloud プロジェクトを作成している。

  • Cloud プロジェクトに、GKE On-Prem が Container Registry からコンポーネントをダウンロードするために使用できるサービス アカウントを作成している。このサービス アカウントは、コンポーネント アクセス サービス アカウントと呼ばれます。

  • Anthos API を有効にしている。この API を有効にすると、料金が発生する場合があります。詳しくは、料金ガイドをご覧ください。

コンポーネント アクセス サービス アカウントを作成した Cloud プロジェクトは、コンポーネント アクセス サービス アカウントの親と呼ばれます。このプロジェクトには、GKE On-Prem 構成ファイルで指定したプロジェクトと同じものを指定できます。また、構成ファイルで指定したすべてのプロジェクトと異なるものにしてもかまいません。

コンポーネント アクセス サービス アカウントの親プロジェクトで必要な 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 On-Prem のサービス アカウントと鍵について詳しく学習する。