From ece6fd90151003cf1e28cc2ce83b1cfa41990f86 Mon Sep 17 00:00:00 2001 From: "xin.li" Date: Mon, 15 May 2023 22:04:32 +0800 Subject: [PATCH] [zh-cn] administer-cluster/verify-signed-artifacts.md Signed-off-by: xin.li --- .../verify-signed-artifacts.md | 104 ++++++++++-------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/content/zh-cn/docs/tasks/administer-cluster/verify-signed-artifacts.md b/content/zh-cn/docs/tasks/administer-cluster/verify-signed-artifacts.md index 0e7b5a9b731..0cbedb8dae0 100644 --- a/content/zh-cn/docs/tasks/administer-cluster/verify-signed-artifacts.md +++ b/content/zh-cn/docs/tasks/administer-cluster/verify-signed-artifacts.md @@ -18,22 +18,18 @@ weight: 420 ## {{% heading "prerequisites" %}} -这些说明适用于 Kubernetes {{< skew currentVersion >}}。 -如果你想要检查其他版本的 Kubernetes 组件的完整性,请查看对应 Kubernetes 版本的文档。 - 你需要安装以下工具: - `cosign`([安装指南](https://docs.sigstore.dev/cosign/installation/)) - `curl`(通常由你的操作系统提供) +- `jq`([下载 jq](https://stedlan.github.io/jq/download/)) + -然后使用 `cosign` 验证二进制文件: +然后使用 `cosign verify-blob` 验证二进制文件: ```shell -cosign verify-blob "$BINARY" --signature "$BINARY".sig --certificate "$BINARY".cert +cosign verify-blob "$BINARY" \ + --signature "$BINARY".sig \ + --certificate "$BINARY".cert \ + --certificate-identity krel-staging@k8s-releng-prod.iam.gserviceaccount.com \ + --certificate-oidc-issuer https://accounts.google.com ``` -cosign 自 v1.9.0 版本开始才能使用 `--certificate` 标志,旧版本的 cosign 请使用 `--cert`。 - {{< note >}} +Cosign 2.0 需要指定 `--certificate-identity` 和 `--certificate-oidc-issuer` 选项。 + 想要进一步了解无密钥签名,请参考 [Keyless Signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures)。 + +Cosign 的早期版本还需要设置 `COSIGN_EXPERIMENTAL=1`。 + +如需更多信息,请参考 +[sigstore Blog](https://blog.sigstore.dev/cosign-2-0-released/) {{< /note >}} ## 验证镜像签名 {#verifying-image-signatures} @@ -102,60 +110,64 @@ the `cosign verify` command: 从这个列表中选择一个镜像,并使用 `cosign verify` 命令来验证它的签名: ```shell -COSIGN_EXPERIMENTAL=1 cosign verify registry.k8s.io/kube-apiserver-amd64:v{{< skew currentPatchVersion >}} +cosign verify registry.k8s.io/kube-apiserver-amd64:v{{< skew currentPatchVersion >}} \ + --certificate-identity krel-trust@k8s-releng-prod.iam.gserviceaccount.com \ + --certificate-oidc-issuer https://accounts.google.com \ + | jq . ``` -{{< note >}} - -`COSIGN_EXPERIMENTAL=1` 用于对以 `KEYLESS` 模式签名的镜像进行验证。想要进一步了解 `KEYLESS`,请参考 -[Keyless Signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures)。 -{{< /note >}} - ### 验证所有控制平面组件镜像 {#verifying-images-for-all-control-plane-components} -验证所有已签名的控制平面组件镜像,请运行以下命令: +验证最新稳定版(v{{< skew currentPatchVersion >}})所有已签名的控制平面组件镜像, +请运行以下命令: ```shell -curl -Ls "https://sbom.k8s.io/$(curl -Ls https://dl.k8s.io/release/stable.txt)/release" | grep "SPDXID: SPDXRef-Package-registry.k8s.io" | grep -v sha256 | cut -d- -f3- | sed 's/-/\//' | sed 's/-v1/:v1/' > images.txt +curl -Ls "https://sbom.k8s.io/$(curl -Ls https://dl.k8s.io/release/stable.txt)/release" \ + | grep "SPDXID: SPDXRef-Package-registry.k8s.io" \ + | grep -v sha256 | cut -d- -f3- | sed 's/-/\//' | sed 's/-v1/:v1/' \ + | sort > images.txt input=images.txt while IFS= read -r image do - COSIGN_EXPERIMENTAL=1 cosign verify "$image" + cosign verify "$image" \ + --certificate-identity krel-trust@k8s-releng-prod.iam.gserviceaccount.com \ + --certificate-oidc-issuer https://accounts.google.com \ + | jq . done < "$input" ``` 当你完成某个镜像的验证时,可以在你的 Pod 清单通过摘要值来指定该镜像,例如: -`registry-url/image-name@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2`。 + +```console +registry-url/image-name@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 +``` 要了解更多信息,请参考[镜像拉取策略](/zh-cn/docs/concepts/containers/images/#image-pull-policy)章节。