使用 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, Infrastructure Manager, Developer Connect, Cloud Build, and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. 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
(
-
安装 Google Cloud CLI。
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
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, Infrastructure Manager, Developer Connect, Cloud Build, and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. 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
(
-
安装 Google Cloud CLI。
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init - 向 App Lifecycle Manager
服务账号 授予所需权限:
依次前往 App Lifecycle Manager > 概览 开始使用。
- 在显示消息 The required permissions for App Lifecycle Manager account haven't been granted 的横幅中,点击 Grant permissions (授予权限)。
使用组合模板对 Cloud SQL 产品进行建模
在本部分中,您将使用 App Lifecycle Manager 对包含 Cloud SQL 实例的组合模板 (sql-quickstart-template) 进行建模,方法是使用 App Design Center。
在 Google Cloud 控制台中,依次前往 App Lifecycle Manager > SaaS 产品。
点击创建 。
在 SaaS 产品名称 字段中,输入
my-sql-quickstart-saas-offering。在区域 下拉列表中,选择以下区域:
us-central1us-east1us-east5
点击确定 。
点击创建 。创建
my-sql-quickstart-saas-offering可能需要几分钟时间。系统会打开 SaaS 产品详情 页面。
在 SaaS 产品详情 页面上,点击创建新模板 。
在创建新的组合模板 页面上:
- 在模板 ID 框中,输入
sql-quickstart-template。 点击创建模板 。App Lifecycle Manager 将需要几分钟时间来创建组合模板。
App Lifecycle Manager 成功创建模板后,您会在 SaaS 产品详情 页面的已关联的应用模板 部分中看到其详细信息。
- 在模板 ID 框中,输入
在已关联的应用模板 部分中,依次前往管理模板 > 在画布中配置 。
App Design Center 会在 Google Cloud 控制台窗口中打开。
在组件 区域中,找到并点击 Cloud SQL (My SQL) 模板。
系统会将 Cloud SQL (My SQL) 组件添加到画布中。
依次点击继续 > 使用 App Lifecycle Manager 进行大规模部署 。
App Lifecycle Manager 会在 Google Cloud 控制台窗口中打开。
在已关联的应用模板 部分中,点击更新模板修订版本 。
在更新模板修订版本 页面上,在修订版本 下拉列表中选择
r-2。点击更新 。已关联的应用模板 部分会显示正在导入应用模板 。
App Lifecycle Manager 可能需要几分钟时间来导入模板修订版本。修订版本导入完成后,您会在单元种类 标签页中看到填充的单元种类列表。
使用 App Lifecycle Manager 预配 Cloud SQL 实例
在本部分中,您将在 us-central1 区域中创建并预配包含 Cloud SQL 实例的单元 (my-sql-quickstart-unit)。
在
my-sql-quickstart-saas-offering的 SaaS 产品详情 页面上,点击预配 。系统会打开预配 页面。
在预配 页面上,在区域 下拉列表中选择
us-central1。点击添加 以将单元添加到您的 SaaS 产品。
在添加要预配的单元 面板上:
- 在单元名称 框中,输入
my-sql-quickstart-unit-1。 - 在单元种类 下拉列表中,选择
sql-quickstart-template单元种类。 - 在版本 下拉列表中,选择 (
r-3)。 - 在服务账号 下拉列表中,选择您在 准备工作部分中创建的服务帐号。
- 在单元名称 框中,输入
点击添加租户项目变量 。
- 选择您的项目以预配资源。
在添加要预配的单元 面板的其他输入变量 部分中:
点击
sql-my-sql-1_database_version下拉列表。- 在变量值 框中,输入
MY_SQL_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,这将在您的 SaaS 产品中创建一个实时 Cloud SQL 实例。App Lifecycle Manager 可能需要几分钟时间来预配
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 账号产生费用,请按照以下步骤操作。
删除项目
如果您在新 Google Cloud 项目中部署了 Cloud SQL 实例,但如果 您不再需要该项目,请完成以下步骤来将其删除:
- 在 Google Cloud 控制台中,前往管理资源页面。
- 在项目列表中,选择要删除的项目,然后点击删除。
- 在提示符处,输入项目 ID,然后点击关停 。
后续步骤
- 如需详细了解 App Lifecycle Manager,请参阅 App Lifecycle Manager 概览。
- 如需开始使用 App Lifecycle Manager,请先创建 SaaS 产品。
- 如需了解服务账号的使用方式以及如何授予这些账号所需的 权限,请参阅 App Lifecycle Manager 服务账号。
- 如需了解更新版本的步骤,请参阅 推出版本。