管理资源

作为 SaaS 提供方或平台管理员,您可以使用 App Lifecycle Manager 在部署后检查和更新 SaaS 产品、单元种类和单元,以调整区域、标签、默认版本和维护固定。这些更新会更改配置元数据,而不会触发基础设施预配。如需发布基础架构更改,请参阅更新 SaaS 产品。如需了解概念背景,请参阅 App Lifecycle Manager 概览。

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud新手,请创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Enable the App Lifecycle Manager API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    gcloud init
  8. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  9. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  10. Enable the App Lifecycle Manager API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. To initialize the gcloud CLI, run the following command:

    gcloud init

所需的角色

如需获得查看和更新 App Lifecycle Manager 资源所需的权限,请让管理员为您授予项目的以下 IAM 角色:

如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

检查资源

在修改资源之前,请检查其配置、位置和标签,以验证您可以修改哪些属性。从下列选项中选择一项:

控制台

  1. 在 Google Cloud 控制台中,前往 SaaS 产品页面:

    前往 SaaS 产品

  2. 点击 SaaS 产品名称,或在导航菜单中选择单位种类或单位,然后点击资源名称。

gcloud

使用 gcloud app-lifecycle-manager saas list 命令列出 SaaS 产品:

gcloud app-lifecycle-manager saas list --location=LOCATION

将 LOCATION 替换为资源位置,例如 global 或 us-central1。

使用 gcloud app-lifecycle-manager saas describe 命令描述特定 SaaS 产品:

gcloud app-lifecycle-manager saas describe \
    SAAS_OFFERING_NAME --location=LOCATION

替换以下内容:

  • SAAS_OFFERING_NAME:SaaS 产品名称
  • LOCATION:资源位置,例如 global 或 us-central1

使用 gcloud app-lifecycle-manager unit-kinds list 命令列出单位类型:

gcloud app-lifecycle-manager unit-kinds list --location=LOCATION

将 LOCATION 替换为资源位置,例如 global 或 us-central1。

使用 gcloud app-lifecycle-manager units list 命令列出单元:

gcloud app-lifecycle-manager units list --location=LOCATION

将 LOCATION 替换为区域级位置,例如 us-central1。单元仅存储在区域级位置,不会复制到 global。

如需检查单个单元种类或单元,请使用 gcloud app-lifecycle-manager unit-kinds describe 命令或 gcloud app-lifecycle-manager units describe 命令。

修改 SaaS 产品

您可以更新 SaaS 产品的可用区域、标签和关联的 Application Design Center 复合模板。资源名称和父级位置不可变。从下列选项中选择一项:

控制台

  1. 在 Google Cloud 控制台中,前往 SaaS 产品页面:

    前往 SaaS 产品

  2. 在名称列中,点击要更新的 SaaS 产品。

  3. 在 SaaS 产品详情页面上,点击 修改。

  4. 在区域列表中,选择或清除区域,然后点击确定;或者在标签部分中,添加、修改或移除键值对。

  5. 点击保存。

gcloud

使用 gcloud app-lifecycle-manager saas update 命令更新 SaaS 产品/服务的区域或标签:

gcloud app-lifecycle-manager saas update \
    SAAS_OFFERING_NAME --location=LOCATION \
    --add-locations=name=REGION \
    --update-labels=KEY=VALUE

替换以下内容:

  • SAAS_OFFERING_NAME:SaaS 产品名称
  • LOCATION:SaaS 产品的位置
  • REGION:要添加的 Google Cloud 区域,例如 europe-west1
  • KEY:要添加或更新的标签键
  • VALUE:要添加或更新的标签值

如需移除位置信息或标签,请传递 --remove-locations=name=REGION 或 --remove-labels=KEY。

关联新模板

如果您的 SaaS 产品未连接任何应用设计中心复合模板,请连接现有模板或创建新模板:

控制台

  1. 在 SaaS 产品/服务详情页面的关联的应用模板下,点击关联现有模板以选择现有模板,或点击创建新模板以在 App Design Center 中设计一个模板。
  2. 按照提示将模板关联到您的 SaaS 产品。

gcloud

通过使用 gcloud app-lifecycle-manager saas update 将其完整资源名称传递给 --application-template,在源区域中连接复合模板:

gcloud app-lifecycle-manager saas update \
    SAAS_OFFERING_NAME --location=LOCATION \
    --application-template=projects/PROJECT_ID/locations/LOCATION/spaces/SPACE/applicationTemplates/TEMPLATE_ID

替换以下内容:

  • SAAS_OFFERING_NAME:SaaS 产品名称
  • LOCATION:SaaS 产品的来源区域
  • PROJECT_ID: Google Cloud 项目 ID
  • SPACE:应用设计中心空间 ID
  • TEMPLATE_ID:复合模板 ID

更新关联的模板

当应用设计中心复合模板已连接时,您可以更新模板修订版本、在设计画布中修改模板、更新依赖项或断开模板连接:

控制台

  1. 在 SaaS 产品/服务详情页面上的关联的应用模板下,点击管理模板。
  2. 从下列选项中选择一项:
    • 更新模板修订版本:选择要更新到的较新模板修订版本,并触发模板重新同步。
    • 在画布中配置:在 App Design Center 画布中打开模板,以修改其组件和配置。
    • 修改依赖项:打开模板详细信息以更新其依赖项。
    • 解除模板关联:移除模板与 SaaS 产品之间的关联,而不删除导入的资源。

gcloud

通过将完整修订版本资源名称传递给 --application-template-revision(使用 gcloud app-lifecycle-manager saas update),在源区域中切换连接的模板修订版本:

gcloud app-lifecycle-manager saas update \
    SAAS_OFFERING_NAME --location=LOCATION \
    --application-template-revision=projects/PROJECT_ID/locations/LOCATION/spaces/SPACE/applicationTemplates/TEMPLATE_ID/revisions/REVISION_ID

替换以下内容:

  • SAAS_OFFERING_NAME:SaaS 产品名称
  • LOCATION:SaaS 产品的来源区域
  • PROJECT_ID: Google Cloud 项目 ID
  • SPACE:应用设计中心空间 ID
  • TEMPLATE_ID:复合模板 ID
  • REVISION_ID:模板修订版本 ID

更改模板修订版本会触发模板重新同步,而不是仅更新元数据。

修改单元种类

您可以在 Google Cloud 控制台中或使用 Google Cloud CLI 更新单元种类的默认版本和标签。单元种类名称、父级 SaaS 产品和依赖项不可变。对于从复合模板导入的单元类型,请在 App Design Center 中管理依赖项和变量映射。 从下列选项中选择一项:

控制台

  1. 在 Google Cloud 控制台中,前往单位种类页面:

    前往“单位种类”

  2. 在名称列中,点击要更新的单位类型。

  3. 在单位种类详情页面上,点击 修改。

  4. 在默认版本列表中,选择一个版本或无默认版本,然后在标签部分中更新标签。

  5. 点击保存。

gcloud

使用 gcloud app-lifecycle-manager unit-kinds update 命令更新单位种类:

gcloud app-lifecycle-manager unit-kinds update \
    UNIT_KIND_NAME --location=LOCATION \
    --default-release=RELEASE_NAME \
    --update-labels=KEY=VALUE

替换以下内容:

  • UNIT_KIND_NAME:单位种类的名称
  • LOCATION:单位类型的位置
  • RELEASE_NAME:单元的默认版本名称
  • KEY:要添加或更新的标签键
  • VALUE:要添加或更新的标签值

如需取消设置默认版本,请在 UNIT_KIND_NAME 之后直接传递 --clear-default-release 标志:

gcloud app-lifecycle-manager unit-kinds update \
    UNIT_KIND_NAME --clear-default-release \
    --location=LOCATION

修改单元

您可以更新单元的标签、租户关联和维护固定设置,而无需触发基础设施预配。单元名称、单元种类和管理模式一经创建便无法更改。如需将单元与租户关联或重新分配其租户,请参阅将单元与租户关联或将 --tenant 传递给 gcloud app-lifecycle-manager units update。从下列选项中选择一项:

控制台

  1. 在 Google Cloud 控制台中,前往单元页面:

    前往“单位”

  2. 在名称列中,点击要更新的单元。

  3. 在单元详情页面上,点击 修改。

  4. 在标签部分中,更新键值对;或者在固定单元部分的固定截止时间字段中,输入未来的日期和时间(或者,如需取消固定单元,请点击清除日期)。

  5. 点击保存。

gcloud

使用 gcloud app-lifecycle-manager units update 命令更新单元的标签或固定其当前版本:

gcloud app-lifecycle-manager units update UNIT_NAME \
    --location=LOCATION \
    --update-labels=KEY=VALUE \
    --maintenance-pinned-until-time=PINNED_UNTIL_TIME

替换以下内容:

  • UNIT_NAME:单元的名称
  • LOCATION:单元的位置
  • KEY:要添加或更新的标签键
  • VALUE:要添加或更新的标签值
  • PINNED_UNTIL_TIME:未来某个时间点的 RFC 3339 时间戳,在此时间点之前,发布会跳过升级单元,例如 2099-12-31T23:59:59Z

如需取消固定单元,请传递过去的时间戳,例如 --maintenance-pinned-until-time=1970-01-01T00:00:00Z。

验证资源更新

在 Google Cloud 控制台中的资源详情页面上确认更改,或使用 gcloud CLI 描述更新后的资源:

gcloud app-lifecycle-manager units describe UNIT_NAME \
    --location=LOCATION

替换以下内容:

  • UNIT_NAME:单元的名称
  • LOCATION:单元的位置

后续步骤