App Lifecycle Manager を使用して MySQL インスタンスをデプロイする
App Lifecycle Manager を使用して Cloud SQL インスタンスをデプロイする方法について説明します。
始める前に
-
ログイン Google アカウントにログインします。
Google アカウントをまだお持ちでない場合は、 新しいアカウントを登録します。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Storage, Developer Connect, Infrastructure Manager, Design Center, App Hub, Cloud Resource Manager, Identity and Access Management, Cloud Asset Inventory, Cloud Monitoring, Cloud Logging, and Service Health APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the App Lifecycle Manager, Artifact Registry, Cloud Build, Cloud Storage, Developer Connect, Infrastructure Manager, Design Center, App Hub, Cloud Resource Manager, Identity and Access Management, Cloud Asset Inventory, Cloud Monitoring, Cloud Logging, and Service Health APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - App Lifecycle Manager
サービス アカウントに必要な権限を付与します:
[App Lifecycle Manager] > [概要] [利用を開始] に移動します。
- [**App Lifecycle Manager アカウントに必要な権限が付与されていません**] というメッセージが表示されたバナーで、[**権限を付与**] をクリックします。
複合テンプレートを使用して Cloud SQL オファリングをモデル化する
このセクションでは、App Lifecycle Manager を使用して、Application Design Center を使用して Cloud SQL インスタンスで構成される複合テンプレート(sql-quickstart-template)をモデル化します。
コンソール Google Cloud で、[App Lifecycle Manager] > [アプリ オファリング] に移動します。
[作成] をクリックします。
[アプリ オファリングの名前] フィールドに「
my-sql-quickstart-saas-offering」と入力します。[リージョン] プルダウンで、次のリージョンを選択します。
us-central1us-east1us-east5
[OK] をクリックします。
[作成] をクリックします。
my-sql-quickstart-saas-offeringの作成には数分かかることがあります。[アプリ オファリングの詳細] ページが開きます。
[アプリ オファリングの詳細] ページで、[新しいテンプレートを作成] をクリックします。
[新しい複合テンプレートの作成] ページで次の操作を行います。
- [テンプレート ID] ボックスに「
sql-quickstart-template」と入力します。 [テンプレートを作成] をクリックします。App Lifecycle Manager で複合テンプレートの作成には数分かかります。
App Lifecycle Manager でテンプレートが正常に作成されると、[アプリ オファリングの詳細] ページの [接続済みのアプリケーション テンプレート] セクションに詳細が表示されます。
- [テンプレート ID] ボックスに「
[接続済みのアプリケーション テンプレート] セクションで、[テンプレートを管理] > [キャンバスで構成] に移動します。
コンソール Google Cloud ウィンドウで Application Design Center が開きます。
[コンポーネント] 領域で、[Cloud SQL(My SQL)] テンプレートを見つけてクリックします。
キャンバスに [Cloud SQL(My SQL)] コンポーネントが追加されます。
[続行] > [App Lifecycle Manager を使用して大規模にデプロイ] をクリックします。
Google Cloud コンソール ウィンドウで App Lifecycle Manager が開きます。
[接続済みのアプリケーション テンプレート] セクションで、[テンプレート リビジョンを更新] をクリックします。
[テンプレート リビジョンを更新] ページの [リビジョン] プルダウンで
r-2を選択します。[更新] をクリックします。[接続済みのアプリケーション テンプレート] セクションに [アプリケーション テンプレートをインポートしています] と表示されます。
App Lifecycle Manager がテンプレート リビジョンをインポートするのに数分かかることがあります。リビジョンのインポートが完了すると、[ユニットの種類] タブにユニットの種類のリストが表示されます。
App Lifecycle Manager を使用して Cloud SQL インスタンスをプロビジョニングする
このセクションでは、us-central1 リージョンに Cloud SQL インスタンスを含むユニット(my-sql-quickstart-unit)を作成してプロビジョニングします。
my-sql-quickstart-saas-offeringの [アプリ オファリングの詳細] ページで、[プロビジョニング] をクリックします。[プロビジョニング] ページが開きます。
[プロビジョニング] ページの [リージョン] プルダウンで
us-central1を選択します。[追加] をクリックして、ユニットをアプリ オファリングに追加します。
[プロビジョニングするユニットの追加] パネルで次の操作を行います。
- [ユニット名] ボックスに「
my-sql-quickstart-unit-1」と入力します。 - [ユニットの種類] プルダウンで、
sql-quickstart-templateユニットの種類を選択します。 - [リリース] プルダウンで、[(
r-3)] を選択します。 - [Service account] プルダウンで、始める前にセクションで 作成したサービス アカウントを選択します。
- [ユニット名] ボックスに「
[テナント プロジェクト変数を追加] をクリックします。
- リソースをプロビジョニングするプロジェクトを選択します。
[プロビジョニングするユニットの追加] パネルの [その他の入力変数] セクションで次の操作を行います。
sql-my-sql-1_database_versionプルダウンをクリックします。- [変数値] ボックスに「
MYSQL_8_0」と入力します。
[完了] をクリックします。
- [変数値] ボックスに「
sql-my-sql-1_nameプルダウンをクリックします。- [変数値] ボックスに「
my-sql-db-1」と入力します。
[完了] をクリックします。
- [変数値] ボックスに「
sql-my-sql-1_project_idプルダウンをクリックします。- [変数値] ボックスにプロジェクト ID を入力します。
[完了] をクリックします。
sql-my-sql-1_regionプルダウンをクリックします。- [変数値] ボックスに「
us-central1」と入力します。
[完了] をクリックします。
- [変数値] ボックスに「
[追加] をクリックします。[プロビジョニングするユニット] テーブルに
my-sql-quickstart-unit-1が表示されます。[プロビジョニング] をクリックして
my-sql-quickstart-unit-1をプロビジョニングします。これにより、アプリ オファリングにライブ Cloud SQL インスタンスが作成されます。my-sql-quickstart-unit-1のプロビジョニングには数分かかることがあります。
デプロイされた Cloud SQL インスタンスを表示する
App Lifecycle Manager を使用して Cloud SQL インスタンスをデプロイしました。
このクイックスタートでデプロイした Cloud SQL インスタンスを表示するには:
コンソール Google Cloud で、[App Lifecycle Manager] > [ユニット] > [ユニットの詳細] ページに移動します。
ユニットの名前(
my-sql-quickstart-unit-1)をクリックします。[ユニットの詳細] ページで次の操作を行います。
[状態] が次のいずれかであることを確認します。
- Cloud SQL インスタンスがプロビジョニングされている場合は [準備完了]。
- オペレーションが進行中の場合は [プロビジョニング中]。
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、 次の手順を実施します。
プロジェクトの削除
Cloud SQL インスタンスを新しい Google Cloud プロジェクトにデプロイした後、そのプロジェクトが不要になった場合は、次の手順で削除します。
- Google Cloud コンソールで [リソースの管理] ページに移動します。
- プロジェクト リストで、削除するプロジェクトを選択し、[削除] をクリックします。
- プロンプトでプロジェクト ID を入力し、[シャットダウン] をクリックします。
次のステップ
- App Lifecycle Manager の詳細については、 App Lifecycle Manager の概要をご覧ください。
- App Lifecycle Manager の使用を開始するには、 アプリ オファリングを作成するから始めます。
- サービス アカウントの使用方法と、これらのアカウントに必要な 権限を付与する方法については、 App Lifecycle Manager サービス アカウントをご覧ください。
- リリースの更新手順については、 リリースをロールアウトするをご覧ください。