@@ -18,22 +18,18 @@ weight: 420
18
18
## {{% heading "prerequisites" %}}
19
19
20
20
<!--
21
- These instructions are for Kubernetes {{< skew currentVersion >}}. If you want
22
- to check the integrity of components for a different version of Kubernetes,
23
- check the documentation for that Kubernetes release.
24
-
25
21
You will need to have the following tools installed:
26
22
27
23
- `cosign` ([install guide](https://docs.sigstore.dev/cosign/installation/))
28
24
- `curl` (often provided by your operating system)
25
+ - `jq` ([download jq](https://stedolan.github.io/jq/download/))
29
26
-->
30
- 这些说明适用于 Kubernetes {{< skew currentVersion >}}。
31
- 如果你想要检查其他版本的 Kubernetes 组件的完整性,请查看对应 Kubernetes 版本的文档。
32
-
33
27
你需要安装以下工具:
34
28
35
29
- ` cosign ` ([ 安装指南] ( https://docs.sigstore.dev/cosign/installation/ ) )
36
30
- ` curl ` (通常由你的操作系统提供)
31
+ - ` jq ` ([ 下载 jq] ( https://stedlan.github.io/jq/download/ ) )
32
+
37
33
38
34
<!--
39
35
## Verifying binary signatures
@@ -45,8 +41,9 @@ binary, retrieve it together with its signature and certificate:
45
41
46
42
## 验证二进制签名 {#verifying-binary-signatures}
47
43
48
- Kubernetes 发布过程使用 cosign 的无密钥签名对所有二进制工件(压缩包、SPDX 文件、 独立的二进制文件)签名。
49
- 要验证一个特定的二进制文件,获取组件时要包含其签名和证书:
44
+ Kubernetes 发布过程使用 cosign 的无密钥签名对所有二进制工件(压缩包、
45
+ SPDX 文件、 独立的二进制文件)签名。要验证一个特定的二进制文件,
46
+ 获取组件时要包含其签名和证书:
50
47
51
48
``` bash
52
49
URL=https://dl.k8s.io/release/v{{< skew currentPatchVersion > }}/bin/linux/amd64
64
61
```
65
62
66
63
<!--
67
- Then verify the blob by using `cosign`:
68
-
69
- cosign v1.9.0 is required to be able to use the `--certificate` flag. Please use
70
- `--cert` for older versions of cosign.
64
+ Then verify the blob by using `cosign verify-blob`:
71
65
-->
72
- 然后使用 ` cosign ` 验证二进制文件:
66
+ 然后使用 ` cosign verify-blob ` 验证二进制文件:
73
67
74
68
``` shell
75
- cosign verify-blob " $BINARY " --signature " $BINARY " .sig --certificate " $BINARY " .cert
69
+ cosign verify-blob " $BINARY " \
70
+ --signature " $BINARY " .sig \
71
+ --certificate " $BINARY " .cert \
72
+ --certificate-identity
[email protected] \
73
+ --certificate-oidc-issuer https://accounts.google.com
76
74
```
77
75
78
- cosign 自 v1.9.0 版本开始才能使用 ` --certificate ` 标志,旧版本的 cosign 请使用 ` --cert ` 。
79
-
80
76
{{< note >}}
81
77
<!--
82
- To learn more about keyless signing, please refer to [Keyless
83
- Signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures).
78
+ Cosign 2.0 requires the `--certificate-identity` and `--certificate-oidc-issuer` options.
79
+
80
+ To learn more about keyless signing, please refer to [Keyless Signatures](https://docs.sigstore.dev/cosign/keyless).
81
+
82
+ Previous versions of Cosign required that you set `COSIGN_EXPERIMENTAL=1`.
83
+
84
+ For additional information, plase refer to the [sigstore Blog](https://blog.sigstore.dev/cosign-2-0-released/)
84
85
-->
86
+ Cosign 2.0 需要指定 ` --certificate-identity ` 和 ` --certificate-oidc-issuer ` 选项。
87
+
85
88
想要进一步了解无密钥签名,请参考
86
89
[ Keyless Signatures] ( https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures ) 。
90
+
91
+ Cosign 的早期版本还需要设置 ` COSIGN_EXPERIMENTAL=1 ` 。
92
+
93
+ 如需更多信息,请参考
94
+ [ sigstore Blog] ( https://blog.sigstore.dev/cosign-2-0-released/ )
87
95
{{< /note >}}
88
96
89
97
<!--
@@ -92,7 +100,7 @@ Signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-sign
92
100
For a complete list of images that are signed please refer
93
101
to [Releases](/releases/download/).
94
102
95
- Let's pick one image from this list and verify its signature using
103
+ Pick one image from this list and verify its signature using
96
104
the `cosign verify` command:
97
105
-->
98
106
## 验证镜像签名 {#verifying-image-signatures}
@@ -102,60 +110,64 @@ the `cosign verify` command:
102
110
从这个列表中选择一个镜像,并使用 ` cosign verify ` 命令来验证它的签名:
103
111
104
112
``` shell
105
- COSIGN_EXPERIMENTAL=1 cosign verify registry.k8s.io/kube-apiserver-amd64:v{{< skew currentPatchVersion > }}
113
+ cosign verify registry.k8s.io/kube-apiserver-amd64:v{{< skew currentPatchVersion > }} \
114
+ --certificate-identity
[email protected] \
115
+ --certificate-oidc-issuer https://accounts.google.com \
116
+ | jq .
106
117
```
107
118
108
- {{< note >}}
109
- <!--
110
- `COSIGN_EXPERIMENTAL=1` is used to allow verification of images signed
111
- in `KEYLESS` mode. To learn more about keyless signing, please refer to
112
- [Keyless Signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures).
113
- -->
114
- ` COSIGN_EXPERIMENTAL=1 ` 用于对以 ` KEYLESS ` 模式签名的镜像进行验证。想要进一步了解 ` KEYLESS ` ,请参考
115
- [ Keyless Signatures] ( https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures ) 。
116
- {{< /note >}}
117
-
118
119
<!--
119
120
### Verifying images for all control plane components
120
121
121
- To verify all signed control plane images, please run this command:
122
+ To verify all signed control plane images for the latest stable version
123
+ (v{{< skew currentPatchVersion >}}), please run the following commands:
122
124
-->
123
125
### 验证所有控制平面组件镜像 {#verifying-images-for-all-control-plane-components}
124
126
125
- 验证所有已签名的控制平面组件镜像,请运行以下命令:
127
+ 验证最新稳定版(v{{< skew currentPatchVersion >}})所有已签名的控制平面组件镜像,
128
+ 请运行以下命令:
126
129
127
130
``` shell
128
- 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
131
+ curl -Ls " https://sbom.k8s.io/$( curl -Ls https://dl.k8s.io/release/stable.txt) /release" \
132
+ | grep " SPDXID: SPDXRef-Package-registry.k8s.io" \
133
+ | grep -v sha256 | cut -d- -f3- | sed ' s/-/\//' | sed ' s/-v1/:v1/' \
134
+ | sort > images.txt
129
135
input=images.txt
130
136
while IFS= read -r image
131
137
do
132
- COSIGN_EXPERIMENTAL=1 cosign verify " $image "
138
+ cosign verify " $image " \
139
+ --certificate-identity
[email protected] \
140
+ --certificate-oidc-issuer https://accounts.google.com \
141
+ | jq .
133
142
done < " $input "
134
143
```
135
144
136
145
<!--
137
- Once you have verified an image, specify that image by its digest in your Pod
138
- manifests as per this
139
- example: `registry-url/image-name@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2`.
146
+ Once you have verified an image, you can specify that image by its digest in your Pod
147
+ manifests as per this example:
140
148
141
149
For more information, please refer
142
- to [Image Pull Policy](/docs/concepts/containers/images/#image-pull-policy)
150
+ to the [Image Pull Policy](/docs/concepts/containers/images/#image-pull-policy)
143
151
section.
144
152
-->
145
153
当你完成某个镜像的验证时,可以在你的 Pod 清单通过摘要值来指定该镜像,例如:
146
- ` registry-url/image-name@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 ` 。
154
+
155
+ ``` console
156
+ registry-url/image-name@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
157
+ ```
147
158
148
159
要了解更多信息,请参考[ 镜像拉取策略] ( /zh-cn/docs/concepts/containers/images/#image-pull-policy ) 章节。
149
160
150
161
<!--
151
162
## Verifying Image Signatures with Admission Controller
152
163
153
- For non-control plane images (
154
- e.g. [conformance image](https://github.com/kubernetes/kubernetes/blob/master/test/conformance/image/README.md))
155
- , signatures can also be verified at deploy time using
164
+ For non-control plane images (for example
165
+ [conformance image](https://github.com/kubernetes/kubernetes/blob/master/test/conformance/image/README.md)),
166
+ signatures can also be verified at deploy time using
156
167
[sigstore policy-controller](https://docs.sigstore.dev/policy-controller/overview)
157
- admission controller. To get started with `policy-controller` here are a few helpful
158
- resources:
168
+ admission controller.
169
+
170
+ Here are some helpful resources to get started with `policy-controller`:
159
171
160
172
* [Installation](https://github.com/sigstore/helm-charts/tree/main/charts/policy-controller)
161
173
* [Configuration Options](https://github.com/sigstore/policy-controller/tree/main/config)
@@ -166,7 +178,7 @@ resources:
166
178
(例如 [ conformance 镜像] ( https://github.com/kubernetes/kubernetes/blob/master/test/conformance/image/README.md ) ),
167
179
也可以在部署时使用
168
180
[ sigstore policy-controller] ( https://docs.sigstore.dev/policy-controller/overview )
169
- 控制器验证其签名。如要使用 ` policy-controller ` ,下面是一些有帮助的资源 :
181
+ 控制器验证其签名。以下是一些有助于你开始使用 ` policy-controller ` 的资源 :
170
182
171
183
- [ 安装] ( https://github.com/sigstore/helm-charts/tree/main/charts/policy-controller )
172
184
- [ 配置选项] ( https://github.com/sigstore/policy-controller/tree/main/config )
0 commit comments