配置一个多项目设置

本教程介绍如何在多项目配置中使用 Binary Authorization。如需了解更简单的单项目配置,请参阅 Google Cloud CLI 使用入门 (GKE)

如需实现职责分离,您可以在多项目配置中设置 Binary Authorization。本教程稍后将讨论每个项目的用途。

目标

在本教程中,您将执行以下任务:

  1. 为部署 (GKE)、证明者和证明管理分别设置不同的项目,以实现职责分离

  2. 配置 Binary Authorization 政策的默认规则以要求提供证明。

  3. 创建公钥基础架构 (X.509) (PKIX) 密钥对,用于对证明进行签名,并在稍后用其对证明进行验证。

  4. 创建一个 Binary Authorization Enforcer 用于验证证明的证明者。

  5. 对示例映像进行签名,以创建证明。

  6. 通过部署示例映像来测试政策。

您必须通过 Identity and Access Management (IAM) 配置每个项目的相应访问权限控制。

如需提升安全性,您可以使用 VPC Service Controls 保护您在本教程中创建的资源。如需了解详情,请参阅使用 VPC Service Controls 进行保护

费用

在本文档中,您将使用 Google Cloud的以下收费组件:

如需根据您的预计使用情况来估算费用,请使用价格计算器

新 Google Cloud 用户可能有资格申请免费试用

准备工作

  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. Verify that billing is enabled for your Google Cloud project.

  4. 安装 Google Cloud CLI。

  5. 如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

  6. 如需初始化 gcloud CLI,请运行以下命令:

    gcloud init
  7. 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

  8. Verify that billing is enabled for your Google Cloud project.

  9. 安装 Google Cloud CLI。

  10. 如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

  11. 如需初始化 gcloud CLI,请运行以下命令: