@@ -145,24 +145,25 @@ so that they don't need to be downloaded again.
145
145
只要能够可靠地访问镜像仓库,底层镜像提供者的缓存语义甚至可以使 ` imagePullPolicy: Always ` 高效。
146
146
你的容器运行时可以注意到节点上已经存在的镜像层,这样就不需要再次下载。
147
147
148
+ {{< note >}}
148
149
<!--
149
150
You should avoid using the `:latest` tag when deploying containers in production as
150
151
it is harder to track which version of the image is running and more difficult to
151
152
roll back properly.
152
153
153
154
Instead, specify a meaningful tag such as `v1.42.0`.
154
-
155
- To make sure the Pod always uses the same version of a container image, you can specify
156
- the image's digest;
157
- replace `<image-name>:<tag>` with `<image-name>@<digest>`
158
- (for example, `image@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2`).
159
155
-->
160
- {{< note >}}
161
156
在生产环境中部署容器时,你应该避免使用 ` :latest ` 标签,因为这使得正在运行的镜像的版本难以追踪,并且难以正确地回滚。
162
157
163
158
相反,应指定一个有意义的标签,如 ` v1.42.0 ` 。
164
159
{{< /note >}}
165
160
161
+ <!--
162
+ To make sure the Pod always uses the same version of a container image, you can specify
163
+ the image's digest;
164
+ replace `<image-name>:<tag>` with `<image-name>@<digest>`
165
+ (for example, `image@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2`).
166
+ -->
166
167
为了确保 Pod 总是使用相同版本的容器镜像,你可以指定镜像的摘要;
167
168
将 ` <image-name>:<tag> ` 替换为 ` <image-name>@<digest> ` ,例如 ` image@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 ` 。
168
169
@@ -345,7 +346,7 @@ These options are explained in more detail below.
345
346
346
347
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.
347
348
-->
348
- ### 配置 Node 对私有仓库认证
349
+ ### 配置 Node 对私有仓库认证 {configuring-nodes-to-authenticate-to-a-private-registry}
349
350
350
351
设置凭据的具体说明取决于你选择使用的容器运行时和仓库。
351
352
你应该参考解决方案的文档来获取最准确的信息。
@@ -423,11 +424,11 @@ term:
423
424
'?' 匹配任意单个非分隔符
424
425
'[' [ '^' ] 字符范围
425
426
字符集(必须非空)
426
- c 匹配字符 c (c 不为 '*','?','\\','[')
427
+ c 匹配字符 c (c 不为 '*', '?', '\\', '[')
427
428
'\\' c 匹配字符 c
428
429
429
430
字符范围:
430
- c 匹配字符 c (c 不为 '\\','?','-',']')
431
+ c 匹配字符 c (c 不为 '\\', '?', '-', ']')
431
432
'\\' c 匹配字符 c
432
433
lo '-' hi 匹配字符范围在 lo 到 hi 之间字符
433
434
```
@@ -483,12 +484,12 @@ authentication sources if one of them fails.
483
484
-->
484
485
### 提前拉取镜像 {#pre-pulled-images}
485
486
487
+ {{< note >}}
486
488
<!--
487
489
This approach is suitable if you can control node configuration. It
488
490
will not work reliably if your cloud provider manages nodes and replaces
489
491
them automatically.
490
492
-->
491
- {{< note >}}
492
493
该方法适用于你能够控制节点配置的场合。
493
494
如果你的云供应商负责管理节点并自动置换节点,这一方案无法可靠地工作。
494
495
{{< /note >}}
@@ -521,11 +522,11 @@ All pods will have read access to any pre-pulled images.
521
522
-->
522
523
### 在 Pod 上指定 ImagePullSecrets {#specifying-imagepullsecrets-on-a-pod}
523
524
525
+ {{< note >}}
524
526
<!--
525
527
This is the recommended approach to run containers based on images
526
528
in private registries.
527
529
-->
528
- {{< note >}}
529
530
运行使用私有仓库中镜像的容器时,建议使用这种方法。
530
531
{{< /note >}}
531
532
@@ -574,11 +575,11 @@ only works with a single private registry.
574
575
如果你在使用多个私有容器仓库,这种技术将特别有用。
575
576
原因是 ` kubectl create secret docker-registry ` 创建的是仅适用于某个私有仓库的 Secret。
576
577
578
+ {{< note >}}
577
579
<!--
578
580
Pods can only reference image pull secrets in their own namespace,
579
581
so this process needs to be done one time per namespace.
580
582
-->
581
- {{< note >}}
582
583
Pod 只能引用位于自身所在名字空间中的 Secret,因此需要针对每个名字空间重复执行上述过程。
583
584
{{< /note >}}
584
585
@@ -591,7 +592,7 @@ reference a Secret in the same namespace.
591
592
592
593
For example:
593
594
-->
594
- #### 在 Pod 中引用 ImagePullSecrets
595
+ #### 在 Pod 中引用 ImagePullSecrets {referring-to-an-imagepullsecrets-on-a-pod}
595
596
596
597
现在,在创建 Pod 时,可以在 Pod 定义中增加 ` imagePullSecrets ` 部分来引用该 Secret。
597
598
` imagePullSecrets ` 数组中的每一项只能引用同一名字空间中的 Secret。
620
621
```
621
622
622
623
<!--
623
- This needs to be done for each pod that is using a private registry.
624
+ This needs to be done for each pod that is using a private registry.
624
625
625
626
However, setting of this field can be automated by setting the imagePullSecrets
626
627
in a [ServiceAccount](/docs/tasks/configure-pod-container/configure-service-account/) resource.
@@ -651,33 +652,31 @@ common use cases and suggested solutions.
651
652
652
653
<!--
653
654
1. Cluster running only non-proprietary (e.g. open-source) images. No need to hide images.
654
- - Use public images on the Docker hub.
655
+ - Use public images from a public registry
655
656
- No configuration required.
656
657
- Some cloud providers automatically cache or mirror public images, which improves availability and reduces the time to pull images.
657
658
-->
658
659
1 . 集群运行非专有镜像(例如,开源镜像)。镜像不需要隐藏。
659
- - 使用 Docker hub 上的公开镜像
660
+ - 使用来自公共仓库的公共镜像
660
661
- 无需配置
661
662
- 某些云厂商会自动为公开镜像提供高速缓存,以便提升可用性并缩短拉取镜像所需时间
662
663
663
664
<!--
664
665
1. Cluster running some proprietary images which should be hidden to those outside the company, but
665
666
visible to all cluster users.
666
- - Use a hosted private [Docker registry](https://docs.docker.com/registry/).
667
- - It may be hosted on the [Docker Hub](https://hub.docker.com/signup), or elsewhere.
668
- - Manually configure .docker/config.json on each node as described above.
667
+ - Use a hosted private registry
668
+ - Manual configuration may be required on the nodes that need to access to private registry
669
669
- Or, run an internal private registry behind your firewall with open read access.
670
670
- No Kubernetes configuration is required.
671
671
- Use a hosted container image registry service that controls image access
672
672
- It will work better with cluster autoscaling than manual node configuration.
673
673
- Or, on a cluster where changing the node configuration is inconvenient, use `imagePullSecrets`.
674
674
-->
675
675
2 . 集群运行一些专有镜像,这些镜像需要对公司外部隐藏,对所有集群用户可见
676
- - 使用托管的私有 [ Docker 仓库] ( https://docs.docker.com/registry/ )
677
- - 可以托管在 [ Docker Hub] ( https://hub.docker.com/account/signup/ ) 或者其他地方
678
- - 按照上面的描述,在每个节点上手动配置 ` .docker/config.json ` 文件
676
+ - 使用托管的私有仓库
677
+ - 在需要访问私有仓库的节点上可能需要手动配置
679
678
- 或者,在防火墙内运行一个组织内部的私有仓库,并开放读取权限
680
- - 不需要配置 Kubenretes
679
+ - 不需要配置 Kubernetes
681
680
- 使用控制镜像访问的托管容器镜像仓库服务
682
681
- 与手动配置节点相比,这种方案能更好地处理集群自动扩缩容
683
682
- 或者,在不方便更改节点配置的集群中,使用 ` imagePullSecrets `
0 commit comments