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

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

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

始める前に

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

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

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

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

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

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
opsconfigmonitoring.googleapis.com
monitoring.googleapis.com
logging.googleapis.com

プロジェクトでサービスを有効にするには、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 \
    opsconfigmonitoring.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 を有効にすると、料金が発生する可能性があります。詳細については、料金ガイドをご覧ください。

ログイン

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

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

gcloud auth login

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

gcloud config list

出力には、SDK account プロパティの値が表示されます。次に例を示します。

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

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

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

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

ロールを付与するには、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: Cloud プロジェクトの ID
  • ACCOUNT: SDK の account プロパティの値

次のステップ

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