本教程介绍了如何配置和测试要求提供证明的 Binary Authorization 政策。此类政策会在允许部署容器映像之前先验证该容器映像是否拥有已获签名的证明,从而保护基于容器的软件供应链的安全。
在部署时,Binary Authorization 使用证明者来验证证明中的数字签名。证明是由签名者创建的,它们通常是持续集成 (CI) 流水线的一部分。
在本教程中,GKE 集群、证明和证明者均位于单个项目中。单项目配置最适合用于测试或试用该服务。如需查看更多实际示例,请参阅多项目配置。
以下步骤介绍了您可以通过命令行执行的任务。如需使用 Google Cloud 控制台执行这些步骤,请参阅 Google Cloud 控制台使用入门。
目标
在本教程中,您将执行以下操作:
- 创建启用了 Binary Authorization 的 Google Kubernetes Engine (GKE) 集群
- 创建一个供 Binary Authorization Enforcer 用于验证证明中的签名的证明者
- 配置要求提供证明的政策
- 创建加密密钥对,用于对证明签名,并在稍后进行验证
- 对容器映像摘要签名,同时创建签名
- 使用签名创建证明
- 通过将容器映像部署到 GKE 来测试政策
费用
在本文档中,您将使用 Google Cloud的以下收费组件:
如需根据您的预计使用情况来估算费用,请使用价格计算器。
准备工作
- 登录您的 Google Cloud 账号。如果您是 Google Cloud新手,请 创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
-
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.
-
安装 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.
-
安装 Google Cloud CLI。
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init - 安装