GCPコトハジメ
何はともあれプロジェクト作成
任意のプロジェクト名とグローバルで一意なプロジェクトIDをつける
開発環境と本番環境で分けるのがベストプラクティスらしい
本番環境での Container Engine の準備 | ソリューション | Google Cloud
プロジェクト名:sample-dev
プロジェクトID:sample-dev
こんな感じでよい
Google Cloud SDK セットアップ(ユーザーアカウント認証)
ユーザーアカウント認証は主にローカルでの使用に使われるはず
Mac OS X 用のクイックスタート | Cloud SDK のドキュメント | Google Cloud
初期化
gcloud init
アカウントとプロジェクトを選択
Choose the account you would like to use to perform operations for this configuration: [1] hoge@candee.co.jp [2] Log in with a new account Please enter your numeric choice: 1 You are logged in as: [yuki.toida@candee.co.jp]. Pick cloud project to use: [1] sample-dev [2] Create a new project Please enter numeric choice or text value (must exactly match list item): 1
GCEのデフォルトゾーン選択
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] asia-east1-c [2] asia-east1-b [3] asia-east1-a [4] asia-northeast1-b [5] asia-northeast1-a [6] asia-northeast1-c [7] asia-southeast1-a [8] asia-southeast1-b [9] australia-southeast1-c [10] australia-southeast1-a [11] australia-southeast1-b [12] europe-west1-d [13] europe-west1-c [14] europe-west1-b [15] europe-west2-c [16] europe-west2-b [17] europe-west2-a [18] europe-west3-b [19] europe-west3-a [20] europe-west3-c [21] southamerica-east1-b [22] southamerica-east1-a [23] southamerica-east1-c [24] us-central1-c [25] us-central1-f [26] us-central1-a [27] us-central1-b [28] us-east1-b [29] us-east1-c [30] us-east1-d [31] us-east4-b [32] us-east4-a [33] us-east4-c [34] us-west1-a [35] us-west1-c [36] us-west1-b [37] Do not set default zone Please enter numeric choice or text value (must exactly match list
Config確認
gcloud config list
問題なければセットアップ完了
Google Cloud SDK セットアップ(サービスアカウント認証)
サービスアカウント認証は主にデプロイサーバ等で使われるはず
Cloud SDK ツールの承認 | Cloud SDK のドキュメント | Google Cloud
Google Cloud Platform Console の [Service Accounts] ページに移動します。 [SERVICE ACCOUNTS] ページに移動 [Create service account] をクリックするか、既存のアカウントを選択します。 サービス アカウントの表の [Options] 列にある [More] ボタン 鍵ファイルを作成する をクリックし、[Create key] を選択して、JSON 形式の鍵ファイルを作成してダウンロードします。 鍵ファイルを作成する 必要に応じて、Cloud SDK ツールを承認するシステム上の場所に鍵ファイルを移動します。 gcloud auth activate-service-account を実行します。 gcloud auth activate-service-account --key-file [KEY_FILE] システムから鍵ファイルを削除します。
これでローカルマシンとデプロイマシンからgcloudコマンドを発行できる