Google Cloud プロジェクト(クイックスタート)

このドキュメントでは、Google Cloud プロジェクトを設定し、Google アカウントにロールを付与する方法について説明します。

この手順はクイックスタートの一部です。Anthos clusters on VMware(GKE on-prem)で Google Cloud プロジェクトを使用する詳しい手順については、複数の Google Cloud プロジェクトの使用をご覧ください。

準備

Anthos clusters on VMware の概要を確認する。

Google Cloud CLI をインストールする

Google Cloud プロジェクトを選択または作成する

Anthos cluster on VMware は、1 つ以上の Goolgle Cloud プロジェクトに関連付ける必要があります。このクイックスタートでは、1 つの Google Cloud プロジェクトのみを使用します。既存の Google Cloud プロジェクトを使用することも、新しい Google Cloud プロジェクトを作成することもできます。プロジェクト ID をメモします。

Google Cloud プロジェクトでサービスを有効にする

Google Cloud プロジェクトで以下のサービスを有効にする必要があります。

anthos.googleapis.com
anthosgke.googleapis.com
anthosaudit.googleapis.com
cloudresourcemanager.googleapis.com
container.googleapis.com
gkeconnect.googleapis.com
gkehub.googleapis.com
serviceusage.googleapis.com
stackdriver.googleapis.com
monitoring.googleapis.com
logging.googleapis.com

プロジェクトでサービスを有効にするには、Google Cloud プロジェクトに対する特定の権限が必要です。詳しくは、アクセス制御services.enable に必要な権限をご覧ください。

必要な権限を持っている場合は、自分でサービスを有効にできます。権限を持っていない場合は、組織内の他のユーザーがサービスを有効にする必要があります。

必要なサービスを有効にするには:

Linux / macOS

gcloud services enable --project=PROJECT_ID \
    anthos.googleapis.com \
    anthosgke.googleapis.com \
    anthosaudit.googleapis.com \
    cloudresourcemanager.googleapis.com \
    container.googleapis.com \
    gkeconnect.googleapis.com \
    gkehub.googleapis.com \
    serviceusage.googleapis.com \
    stackdriver.googleapis.com \
    monitoring.googleapis.com \
    logging.googleapis.com

Windows

gcloud services enable --project=PROJECT_ID ^
    anthos.googleapis.com ^
    anthosgke.googleapis.com ^
    anthosaudit.googleapis.com ^
    cloudresourcemanager.googleapis.com ^
    container.googleapis.com ^
    gkeconnect.googleapis.com ^
    gkehub.googleapis.com ^
    serviceusage.googleapis.com ^
    stackdriver.googleapis.com ^
    monitoring.googleapis.com ^
    logging.googleapis.com

anthos.googleapis.com を有効にすると、料金が発生する可能性があります。詳細については、料金ガイドをご覧ください。

ログインして SDK プロパティを設定する

gkeadm コマンドライン ツールで SDK account と SDK projectプロパティを使用してサービス アカウントを作成し、クラスタ構成ファイルのフィールドにデータを入力します。つまり gkeadm を実行して管理ワークステーションを作成する前に、これらのプロパティを設定することが重要です。

任意の Google アカウントでログインします。SDK の account プロパティが設定されます。

gcloud auth login

次に、SDK の project プロパティを設定します。

gcloud config set project PROJECT_ID

SDK の accountproject のプロパティが正しく設定されていることを確認します。

gcloud config list

出力には、SDK account と SDK project の各プロパティの値が表示されます。例:

[core]
account = my-name@google.com
disable_usage_reporting = False
project = my-project-123
Your active configuration is: [default]

SDK アカウントにロールを付与する

gkeadm がサービス アカウントを作成、管理できるように、SDK の account プロパティとして設定された Google アカウントには次の IAM ロールが必要です。

  • resourcemanager.projectIamAdmin
  • serviceusage.serviceUsageAdmin
  • iam.serviceAccountCreator
  • iam.serviceAccountKeyAdmin

ロールを付与するには、Google Cloud プロジェクトに対する特定の権限が必要です。詳細については、リソースへのアクセス権の付与、変更、取り消しをご覧ください。

必要な権限があれば、自分でロールを付与できます。それ以外の場合は、組織内の別のユーザーがロールを付与する必要があります。

ロールを付与するには:

Linux / macOS

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="user:ACCOUNT" \
    --role="roles/resourcemanager.projectIamAdmin"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="user:ACCOUNT" \
    --role="roles/serviceusage.serviceUsageAdmin"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="user:ACCOUNT" \
    --role="roles/iam.serviceAccountCreator"

gcloud projects add-iam-policy-binding PROJECT_ID \
    --member="user:ACCOUNT" \
    --role="roles/iam.serviceAccountKeyAdmin"

Windows

gcloud projects add-iam-policy-binding PROJECT_ID ^
    --member="user:ACCOUNT" ^
    --role="roles/resourcemanager.projectIamAdmin"

gcloud projects add-iam-policy-binding PROJECT_ID ^
    --member="user:ACCOUNT" ^
    --role="roles/serviceusage.serviceUsageAdmin"

gcloud projects add-iam-policy-binding PROJECT_ID ^
    --member="user:ACCOUNT" ^
    --role="roles/iam.serviceAccountCreator"

gcloud projects add-iam-policy-binding PROJECT_ID ^
    --member="user:ACCOUNT" ^
    --role="roles/iam.serviceAccountKeyAdmin"

以下を置き換えます。

  • PROJECT_ID: SDK の project プロパティの値
  • ACCOUNT: SDK の account プロパティの値

次のステップ

サービス アカウントを作成する(クイックスタート)