Skip to content

Commit 2a6cab7

Browse files
authored
Merge pull request #38829 from windsonsea/imagesy
[zh] sync /concepts/containers/images.md
2 parents 8a54137 + 859c98b commit 2a6cab7

File tree

1 file changed

+63
-44
lines changed
  • content/zh-cn/docs/concepts/containers

1 file changed

+63
-44
lines changed

content/zh-cn/docs/concepts/containers/images.md

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ software dependencies. Container images are executable software bundles that can
2222
standalone and that make very well defined assumptions about their runtime environment.
2323
2424
You typically create a container image of your application and push it to a registry
25-
before referring to it in a
26-
{{< glossary_tooltip text="Pod" term_id="pod" >}}
25+
before referring to it in a {{< glossary_tooltip text="Pod" term_id="pod" >}}.
2726
2827
This page provides an outline of the container image concept.
2928
-->
@@ -67,7 +66,7 @@ Tags let you identify different versions of the same series of images.
6766

6867
如果你不指定仓库的主机名,Kubernetes 认为你在使用 Docker 公共仓库。
6968

70-
在镜像名称之后,你可以添加一个标签(Tag)(与使用 `docker``podman` 等命令时的方式相同)。
69+
在镜像名称之后,你可以添加一个**标签(Tag)**(与使用 `docker``podman` 等命令时的方式相同)。
7170
使用标签能让你辨识同一镜像序列中的不同版本。
7271

7372
<!--
@@ -124,10 +123,10 @@ these values have:
124123
`Always`
125124
: every time the kubelet launches a container, the kubelet queries the container
126125
image registry to resolve the name to an image
127-
[digest](https://docs.docker.com/engine/reference/commandline/pull/#pull-an-image-by-digest-immutable-identifier). If the kubelet has a
128-
container image with that exact digest cached locally, the kubelet uses its cached
129-
image; otherwise, the kubelet pulls the image with the resolved digest,
130-
and uses that image to launch the container.
126+
[digest](https://docs.docker.com/engine/reference/commandline/pull/#pull-an-image-by-digest-immutable-identifier).
127+
If the kubelet has a container image with that exact digest cached locally, the kubelet uses its
128+
cached image; otherwise, the kubelet pulls the image with the resolved digest, and uses that image
129+
to launch the container.
131130
132131
`Never`
133132
: the kubelet does not try fetching the image. If the image is somehow already present
@@ -180,7 +179,11 @@ replace `<image-name>:<tag>` with `<image-name>@<digest>`
180179
`<image-name>:<tag>` 替换为 `<image-name>@<digest>`,例如 `image@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2`
181180

182181
<!--
183-
When using image tags, if the image registry were to change the code that the tag on that image represents, you might end up with a mix of Pods running the old and new code. An image digest uniquely identifies a specific version of the image, so Kubernetes runs the same code every time it starts a container with that image name and digest specified. Specifying an image by digest fixes the code that you run so that a change at the registry cannot lead to that mix of versions.
182+
When using image tags, if the image registry were to change the code that the tag on that image
183+
represents, you might end up with a mix of Pods running the old and new code. An image digest
184+
uniquely identifies a specific version of the image, so Kubernetes runs the same code every time
185+
it starts a container with that image name and digest specified. Specifying an image by digest
186+
fixes the code that you run so that a change at the registry cannot lead to that mix of versions.
184187
185188
There are third-party [admission controllers](/docs/reference/access-authn-authz/admission-controllers/)
186189
that mutate Pods (and pod templates) when they are created, so that the
@@ -249,7 +252,8 @@ If you would like to always force a pull, you can do one of the following:
249252
Kubernetes will set the policy to `Always` when you submit the Pod.
250253
- Omit the `imagePullPolicy` and the tag for the image to use;
251254
Kubernetes will set the policy to `Always` when you submit the Pod.
252-
- Enable the [AlwaysPullImages](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages) admission controller.
255+
- Enable the [AlwaysPullImages](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages)
256+
admission controller.
253257
-->
254258
#### 必要的镜像拉取 {#required-image-pull}
255259

@@ -262,7 +266,6 @@ If you would like to always force a pull, you can do one of the following:
262266
当你提交 Pod 时,Kubernetes 会将策略设置为 `Always`
263267
- 启用准入控制器 [AlwaysPullImages](/zh-cn/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages)
264268

265-
266269
<!--
267270
### ImagePullBackOff
268271
@@ -293,9 +296,18 @@ Kubernetes 会增加每次尝试之间的延迟,直到达到编译限制,即
293296
<!--
294297
## Multi-architecture images with image indexes
295298
296-
As well as providing binary images, a container registry can also serve a [container image index](https://github.com/opencontainers/image-spec/blob/master/image-index.md). An image index can point to multiple [image manifests](https://github.com/opencontainers/image-spec/blob/master/manifest.md) for architecture-specific versions of a container. The idea is that you can have a name for an image (for example: `pause`, `example/mycontainer`, `kube-apiserver`) and allow different systems to fetch the right binary image for the machine architecture they are using.
299+
As well as providing binary images, a container registry can also serve a
300+
[container image index](https://github.com/opencontainers/image-spec/blob/master/image-index.md).
301+
An image index can point to multiple [image manifests](https://github.com/opencontainers/image-spec/blob/master/manifest.md)
302+
for architecture-specific versions of a container. The idea is that you can have a name for an image
303+
(for example: `pause`, `example/mycontainer`, `kube-apiserver`) and allow different systems to
304+
fetch the right binary image for the machine architecture they are using.
297305
298-
Kubernetes itself typically names container images with a suffix `-$(ARCH)`. For backward compatibility, please generate the older images with suffixes. The idea is to generate say `pause` image which has the manifest for all the arch(es) and say `pause-amd64` which is backwards compatible for older configurations or YAML files which may have hard coded the images with suffixes.
306+
Kubernetes itself typically names container images with a suffix `-$(ARCH)`. For backward
307+
compatibility, please generate the older images with suffixes. The idea is to generate say `pause`
308+
image which has the manifest for all the arch(es) and say `pause-amd64` which is backwards
309+
compatible for older configurations or YAML files which may have hard coded the images with
310+
suffixes.
299311
-->
300312
## 带镜像索引的多架构镜像 {#multi-architecture-images-with-image-indexes}
301313

@@ -324,27 +336,27 @@ Credentials can be provided in several ways:
324336
凭据可以用以下方式提供:
325337

326338
<!--
327-
- Configuring Nodes to Authenticate to a Private Registry
328-
- all pods can read any configured private registries
329-
- requires node configuration by cluster administrator
330-
- Kubelet Credential Provider to dynamically fetch credentials for private registries
331-
- kubelet can be configured to use credential provider exec plugin
332-
for the respective private registry.
333-
- Pre-pulled Images
334-
- all pods can use any images cached on a node
335-
- requires root access to all nodes to set up
336-
- Specifying ImagePullSecrets on a Pod
337-
- only pods which provide own keys can access the private registry
338-
- Vendor-specific or local extensions
339-
- if you're using a custom node configuration, you (or your cloud
340-
provider) can implement your mechanism for authenticating the node
341-
to the container registry.
339+
- Configuring Nodes to Authenticate to a Private Registry
340+
- all pods can read any configured private registries
341+
- requires node configuration by cluster administrator
342+
- Kubelet Credential Provider to dynamically fetch credentials for private registries
343+
- kubelet can be configured to use credential provider exec plugin
344+
for the respective private registry.
345+
- Pre-pulled Images
346+
- all pods can use any images cached on a node
347+
- requires root access to all nodes to set up
348+
- Specifying ImagePullSecrets on a Pod
349+
- only pods which provide own keys can access the private registry
350+
- Vendor-specific or local extensions
351+
- if you're using a custom node configuration, you (or your cloud
352+
provider) can implement your mechanism for authenticating the node
353+
to the container registry.
342354
-->
343355
- 配置节点向私有仓库进行身份验证
344356
- 所有 Pod 均可读取任何已配置的私有仓库
345357
- 需要集群管理员配置节点
346358
- kubelet 凭据提供程序,动态获取私有仓库的凭据
347-
- kubelet 可以被配置为使用凭据提供程序 exec 插件来访问对应的私有镜像库
359+
- kubelet 可以被配置为使用凭据提供程序 exec 插件来访问对应的私有镜像库
348360
- 预拉镜像
349361
- 所有 Pod 都可以使用节点上缓存的所有镜像
350362
- 需要所有节点的 root 访问权限才能进行设置
@@ -361,7 +373,8 @@ These options are explained in more detail below.
361373
<!--
362374
### Configuring nodes to authenticate to a private registry
363375
364-
Specific instructions for setting credentials depends on the container runtime and registry you chose to use. You should refer to your solution's documentation for the most accurate information.
376+
Specific instructions for setting credentials depends on the container runtime and registry you
377+
chose to use. You should refer to your solution's documentation for the most accurate information.
365378
-->
366379
### 配置 Node 对私有仓库认证 {#configuring-nodes-to-authenticate-to-a-private-registry}
367380

@@ -411,6 +424,7 @@ prefix-matched paths. This means that a `config.json` like this is valid:
411424
对于 `config.json` 的解释在原始 Docker 实现和 Kubernetes 的解释之间有所不同。
412425
在 Docker 中,`auths` 键只能指定根 URL,而 Kubernetes 允许 glob URLs 以及前缀匹配的路径。
413426
这意味着,像这样的 `config.json` 是有效的:
427+
414428
```json
415429
{
416430
"auths": {
@@ -443,6 +457,7 @@ character-range:
443457
```
444458
-->
445459
使用以下语法匹配根 URL (`*my-registry.io`):
460+
446461
```
447462
pattern:
448463
{ term }
@@ -465,12 +480,6 @@ term:
465480
Image pull operations would now pass the credentials to the CRI container
466481
runtime for every valid pattern. For example the following container image names
467482
would match successfully:
468-
469-
- `my-registry.io/images`
470-
- `my-registry.io/images/my-image`
471-
- `my-registry.io/images/another-image`
472-
- `sub.my-registry.io/images/my-image`
473-
- `a.sub.my-registry.io/images/my-image`
474483
-->
475484
现在镜像拉取操作会将每种有效模式的凭据都传递给 CRI 容器运行时。例如下面的容器镜像名称会匹配成功:
476485

@@ -535,7 +544,8 @@ then a local image is used (preferentially or exclusively, respectively).
535544
If you want to rely on pre-pulled images as a substitute for registry authentication,
536545
you must ensure all nodes in the cluster have the same pre-pulled images.
537546
538-
This can be used to preload certain images for speed or as an alternative to authenticating to a private registry.
547+
This can be used to preload certain images for speed or as an alternative to authenticating to a
548+
private registry.
539549
540550
All pods will have read access to any pre-pulled images.
541551
-->
@@ -580,14 +590,19 @@ Run the following command, substituting the appropriate uppercase values:
580590
运行以下命令,注意替换适当的大写值:
581591

582592
```shell
583-
kubectl create secret docker-registry <name> --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
593+
kubectl create secret docker-registry <name> \
594+
--docker-server=DOCKER_REGISTRY_SERVER \
595+
--docker-username=DOCKER_USER \
596+
--docker-password=DOCKER_PASSWORD \
597+
--docker-email=DOCKER_EMAIL
584598
```
585599

586600
<!--
587601
If you already have a Docker credentials file then, rather than using the above
588602
command, you can import the credentials file as a Kubernetes
589603
{{< glossary_tooltip text="Secrets" term_id="secret" >}}.
590-
[Create a Secret based on existing Docker credentials](/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials) explains how to set this up.
604+
[Create a Secret based on existing Docker credentials](/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials)
605+
explains how to set this up.
591606
-->
592607
如果你已经有 Docker 凭据文件,则可以将凭据文件导入为 Kubernetes
593608
{{< glossary_tooltip text="Secret" term_id="secret" >}},
@@ -654,7 +669,8 @@ This needs to be done for each pod that is using a private registry.
654669
However, setting of this field can be automated by setting the imagePullSecrets
655670
in a [ServiceAccount](/docs/tasks/configure-pod-container/configure-service-account/) resource.
656671
657-
Check [Add ImagePullSecrets to a Service Account](/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account) for detailed instructions.
672+
Check [Add ImagePullSecrets to a Service Account](/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account)
673+
for detailed instructions.
658674
659675
You can use this in conjunction with a per-node `.docker/config.json`. The credentials
660676
will be merged.
@@ -682,7 +698,8 @@ common use cases and suggested solutions.
682698
1. Cluster running only non-proprietary (e.g. open-source) images. No need to hide images.
683699
- Use public images from a public registry
684700
- No configuration required.
685-
- Some cloud providers automatically cache or mirror public images, which improves availability and reduces the time to pull images.
701+
- Some cloud providers automatically cache or mirror public images, which improves
702+
availability and reduces the time to pull images.
686703
-->
687704
1. 集群运行非专有镜像(例如,开源镜像)。镜像不需要隐藏。
688705
- 使用来自公共仓库的公共镜像
@@ -711,7 +728,8 @@ common use cases and suggested solutions.
711728

712729
<!--
713730
1. Cluster with proprietary images, a few of which require stricter access control.
714-
- Ensure [AlwaysPullImages admission controller](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages) is active. Otherwise, all Pods potentially have access to all images.
731+
- Ensure [AlwaysPullImages admission controller](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages)
732+
is active. Otherwise, all Pods potentially have access to all images.
715733
- Move sensitive data into a "Secret" resource, instead of packaging it in an image.
716734
-->
717735
3. 集群使用专有镜像,且有些镜像需要更严格的访问控制
@@ -720,9 +738,11 @@ common use cases and suggested solutions.
720738

721739
<!--
722740
1. A multi-tenant cluster where each tenant needs own private registry.
723-
- Ensure [AlwaysPullImages admission controller](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages) is active. Otherwise, all Pods of all tenants potentially have access to all images.
741+
- Ensure [AlwaysPullImages admission controller](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages)
742+
is active. Otherwise, all Pods of all tenants potentially have access to all images.
724743
- Run a private registry with authorization required.
725-
- Generate registry credential for each tenant, put into secret, and populate secret to each tenant namespace.
744+
- Generate registry credential for each tenant, put into secret, and populate secret to each
745+
tenant namespace.
726746
- The tenant adds that secret to imagePullSecrets of each namespace.
727747
-->
728748
4. 集群是多租户的并且每个租户需要自己的私有仓库
@@ -736,7 +756,6 @@ If you need access to multiple registries, you can create one secret for each re
736756
-->
737757
如果你需要访问多个仓库,可以为每个仓库创建一个 Secret。
738758

739-
740759
## {{% heading "whatsnext" %}}
741760

742761
<!--

0 commit comments

Comments
 (0)