使用 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.
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
(
-
安装 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, 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.
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
(
-
安装 Google Cloud CLI。
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init - 向 App Lifecycle Manager 服务账号授予所需权限:
依次前往 App Lifecycle Manager > 概览 开始。
- 在显示消息“尚未授予 App Lifecycle Manager 账号所需权限”的横幅中,点击授予权限。
使用复合模板对 Cloud SQL 产品进行建模
在本部分中,您将使用 App Lifecycle Manager 通过 App Design Center 对包含 Cloud SQL 实例的复合模板 (sql-quickstart-template) 进行建模。
在 Google Cloud 控制台中,依次前往 App Lifecycle Manager > SaaS 产品。
点击创建。
在 Name of the SaaS offering 字段中,输入:
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 (MySQL) 模板。
系统会将 Cloud SQL (MySQL) 组件添加到画布中。
依次点击继续 > 使用 App Lifecycle Manager 进行大规模部署。
App Lifecycle Manager 会在 Google Cloud 控制台窗口中打开。
在关联的应用模板部分中,点击更新模板修订版本。
在更新模板修订版本页面上,从修订版本下拉菜单中选择
r-2。点击更新。已关联的应用模板部分会显示正在导入应用模板。
App Lifecycle Manager 可能需要几分钟时间才能导入模板修订版本。修订版本导入完成后,您会在单元种类标签页中看到填充的单元种类列表。
使用 App Lifecycle Manager 预配 Cloud SQL 实例
在本部分中,您将创建并预配一个单元 (my-sql-quickstart-unit),其中包含 us-central1 区域中的 Cloud SQL 实例。
在
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下拉菜单。- 在变量值框中,输入
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。点击 Provision 以预配
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 服务账号。
- 如需了解更新版本的步骤,请参阅发布版本。