Skip to content

Commit fdeb85f

Browse files
authored
Merge pull request #41154 from my-git9/path-17075
[zh-cn] sync network-policies.md and volumes.md
2 parents 10bfb1c + 6c465ce commit fdeb85f

File tree

2 files changed

+86
-20
lines changed

2 files changed

+86
-20
lines changed

content/zh-cn/docs/concepts/services-networking/network-policies.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ This policy contains a single `from` element allowing connections from Pods with
309309
`role=client` in namespaces with the label `user=alice`. But the following policy is different:
310310
-->
311311
此策略在 `from` 数组中仅包含一个元素,只允许来自标有 `role=client` 的 Pod
312-
且该 Pod 所在的名字空间中标有 `user=alice` 的连接。但是 **这项** 策略:
312+
且该 Pod 所在的名字空间中标有 `user=alice` 的连接。但是**这项**策略:
313313

314314
```yaml
315315
...
@@ -330,7 +330,7 @@ Namespace with the label `role=client`, *or* from any Pod in any namespace with
330330
`user=alice`.
331331
-->
332332
它在 `from` 数组中包含两个元素,允许来自本地名字空间中标有 `role=client`
333-
Pod 的连接,**** 来自任何名字空间中标有 `user=alice` 的任何 Pod 的连接。
333+
Pod 的连接,****来自任何名字空间中标有 `user=alice` 的任何 Pod 的连接。
334334

335335
<!--
336336
When in doubt, use `kubectl describe` to see how Kubernetes has interpreted the policy.
@@ -388,7 +388,7 @@ in that namespace.
388388
You can create a "default" ingress isolation policy for a namespace by creating a NetworkPolicy
389389
that selects all pods but does not allow any ingress traffic to those pods.
390390
-->
391-
你可以通过创建选择所有容器但不允许任何进入这些容器的入站流量的 NetworkPolicy
391+
你可以通过创建选择所有 Pod 但不允许任何进入这些 Pod 的入站流量的 NetworkPolicy
392392
来为名字空间创建 “default” 隔离策略。
393393

394394
{{< codenew file="service/networking/network-policy-default-deny-ingress.yaml" >}}
@@ -562,6 +562,58 @@ NetworkPolicy 规约中使用 `endPort` 字段。
562562
策略只对单个 `port` 字段生效。
563563
{{< /note >}}
564564

565+
<!--
566+
## Targeting multiple namespaces by label
567+
568+
In this scenario, your `Egress` NetworkPolicy targets more than one namespace using their
569+
label names. For this to work, you need to label the target namespaces. For example:
570+
-->
571+
## 按标签选择多个命名空间 {#targeting-multiple-namespaces-by-label}
572+
573+
在这种情况下,你的 `Egress` NetworkPolicy 使用名字空间的标签名称来将多个名字空间作为其目标。
574+
为此,你需要为目标名字空间设置标签。例如:
575+
576+
```shell
577+
kubectl label namespace frontend namespace=frontend
578+
kubectl label namespace backend namespace=backend
579+
```
580+
581+
<!--
582+
Add the labels under `namespaceSelector` in your NetworkPolicy document. For example:
583+
-->
584+
在 NetworkPolicy 文档中的 namespaceSelector 下添加标签。例如:
585+
586+
```yaml
587+
apiVersion: networking.k8s.io/v1
588+
kind: NetworkPolicy
589+
metadata:
590+
name: egress-namespaces
591+
spec:
592+
podSelector:
593+
matchLabels:
594+
app: myapp
595+
policyTypes:
596+
- Egress
597+
egress:
598+
- to:
599+
- namespaceSelector:
600+
matchExpressions:
601+
- key: namespace
602+
operator: In
603+
values: ["frontend", "backend"]
604+
```
605+
606+
{{< note >}}
607+
<!--
608+
It is not possible to directly specify the name of the namespaces in a NetworkPolicy.
609+
You must use a `namespaceSelector` with `matchLabels` or `matchExpressions` to select the
610+
namespaces based on their labels.
611+
-->
612+
你不可以在 NetworkPolicy 中直接指定命名空间的名称。
613+
你必须使用带有 `matchLabels` 或 `matchExpressions` 的 `namespaceSelector`
614+
来根据标签选择命名空间。
615+
{{< /note >}}
616+
565617
<!--
566618
## Targeting a Namespace by its name
567619
-->

content/zh-cn/docs/concepts/storage/volumes.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,24 @@ weight: 10
1919

2020
<!--
2121
On-disk files in a container are ephemeral, which presents some problems for
22-
non-trivial applications when running in containers. One problem
23-
is the loss of files when a container crashes. The kubelet restarts the container
24-
but with a clean state. A second problem occurs when sharing files
25-
between containers running together in a `Pod`.
22+
non-trivial applications when running in containers. One problem occurs when
23+
a container crashes or is stopped. Container state is not saved so all of the
24+
files that were created or modified during the lifetime of the container are lost.
25+
During a crash, kubelet restarts the container with a clean state.
26+
Another problem occurs when multiple containers are running in a `Pod` and
27+
need to share files. It can be challenging to setup
28+
and access a shared filesystem across all of the containers.
2629
The Kubernetes {{< glossary_tooltip text="volume" term_id="volume" >}} abstraction
2730
solves both of these problems.
2831
Familiarity with [Pods](/docs/concepts/workloads/pods/) is suggested.
2932
-->
30-
Container 中的文件在磁盘上是临时存放的,这给 Container 中运行的较重要的应用程序带来一些问题。
31-
问题之一是当容器崩溃时文件丢失。
32-
kubelet 会重新启动容器,但容器会以干净的状态重启。
33-
第二个问题会在同一 `Pod` 中运行多个容器并共享文件时出现。
33+
容器中的文件在磁盘上是临时存放的,这给在容器中运行较重要的应用带来一些问题。
34+
当容器崩溃或停止时会出现一个问题。此时容器状态未保存,
35+
因此在容器生命周期内创建或修改的所有文件都将丢失。
36+
在崩溃期间,kubelet 会以干净的状态重新启动容器。
37+
当多个容器在一个 Pod 中运行并且需要共享文件时,会出现另一个问题。
38+
跨所有容器设置和访问共享文件系统具有一定的挑战性。
39+
3440
Kubernetes {{< glossary_tooltip text="卷(Volume)" term_id="volume" >}}
3541
这一抽象概念能够解决这两个问题。
3642

@@ -56,14 +62,16 @@ Docker 提供卷驱动程序,但是其功能非常有限。
5662
<!--
5763
Kubernetes supports many types of volumes. A {{< glossary_tooltip term_id="pod" text="Pod" >}}
5864
can use any number of volume types simultaneously.
59-
Ephemeral volume types have a lifetime of a pod, but persistent volumes exist beyond
65+
[Ephemeral volume](/docs/concepts/storage/ephemeral-volumes/) types have a lifetime of a pod,
66+
but [persistent volumes](/docs/concepts/storage/persistent-volumes/) exist beyond
6067
the lifetime of a pod. When a pod ceases to exist, Kubernetes destroys ephemeral volumes;
6168
however, Kubernetes does not destroy persistent volumes.
6269
For any kind of volume in a given pod, data is preserved across container restarts.
6370
-->
6471
Kubernetes 支持很多类型的卷。
6572
{{< glossary_tooltip term_id="pod" text="Pod" >}} 可以同时使用任意数目的卷类型。
66-
临时卷类型的生命周期与 Pod 相同,但持久卷可以比 Pod 的存活期长。
73+
[临时卷](/zh-cn/docs/concepts/storage/ephemeral-volumes/)类型的生命周期与 Pod 相同,
74+
[持久卷](/zh-cn/docs/concepts/storage/persistent-volumes/)可以比 Pod 的存活期长。
6775
当 Pod 不再存在时,Kubernetes 也会销毁临时卷;不过 Kubernetes 不会销毁持久卷。
6876
对于给定 Pod 中任何类型的卷,在容器重启期间数据都不会丢失。
6977

@@ -1943,20 +1951,26 @@ persistent volume:
19431951
secrets are passed. When you have configured secret data for node-initiated
19441952
volume expansion, the kubelet passes that data via the `NodeExpandVolume()`
19451953
call to the CSI driver. In order to use the `nodeExpandSecretRef` field, your
1946-
cluster should be running Kubernetes version 1.25 or later and you must enable
1954+
cluster should be running Kubernetes version 1.25 or later.
1955+
If you are running Kubernetes Version 1.25 or 1.26, you must enable
19471956
the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
19481957
named `CSINodeExpandSecret` for each kube-apiserver and for the kubelet on every
1949-
node. You must also be using a CSI driver that supports or requires secret data during
1958+
node. In Kubernetes version 1.27 this feature has been enabled by default
1959+
and no explicit enablement of the feature gate is required.
1960+
You must also be using a CSI driver that supports or requires secret data during
19501961
node-initiated storage resize operations.
19511962
-->
19521963
* `nodeExpandSecretRef`:对包含敏感信息的 Secret 对象的引用,
19531964
该信息会传递给 CSI 驱动以完成 CSI `NodeExpandVolume` 调用。
19541965
此字段是可选的,如果不需要 Secret,则可能是空的。
19551966
如果 Secret 包含多个 Secret 条目,则传递所有 Secret 条目。
1956-
当你为节点初始化的卷扩展配置 Secret 数据时,kubelet 会通过 `NodeExpandVolume()` 调用将该数据传递给 CSI 驱动。
1957-
为了使用 `nodeExpandSecretRef` 字段,你的集群应运行 Kubernetes 1.25 或更高版本,
1958-
并且你必须为每个 kube-apiserver 和每个节点上的 kubelet 启用名为 `CSINodeExpandSecret`
1967+
当你为节点初始化的卷扩展配置 Secret 数据时,kubelet 会通过 `NodeExpandVolume()`
1968+
调用将该数据传递给 CSI 驱动。为了使用 `nodeExpandSecretRef` 字段,
1969+
你的集群应运行 Kubernetes 1.25 或更高版本,
1970+
如果你所运行的 Kubernetes 是 1.25 或 1.26,你必须为每个 kube-apiserver
1971+
和每个节点上的 kubelet 启用名为 `CSINodeExpandSecret`
19591972
的[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
1973+
在 Kubernetes 1.27 版本中,此特性已默认启用,无需显式启用特性门控。
19601974
在节点初始化的存储大小调整操作期间,你还必须使用支持或需要 Secret 数据的 CSI 驱动。
19611975

19621976
<!--
@@ -2115,7 +2129,8 @@ FlexVolume 是一个使用基于 exec 的模型来与驱动程序对接的树外
21152129
驱动程序可执行文件,在某些情况下,控制平面节点中也要安装。
21162130

21172131
Pod 通过 `flexvolume` 树内插件与 FlexVolume 驱动程序交互。
2118-
更多详情请参考 FlexVolume [README](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md#readme) 文档。
2132+
更多详情请参考 FlexVolume
2133+
[README](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md#readme) 文档。
21192134

21202135
<!--
21212136
The following FlexVolume [plugins](https://github.com/Microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows),
@@ -2273,4 +2288,3 @@ sudo systemctl restart docker
22732288
Follow an example of [deploying WordPress and MySQL with Persistent Volumes](/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/).
22742289
-->
22752290
参考[使用持久卷部署 WordPress 和 MySQL](/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/) 示例。
2276-

0 commit comments

Comments
 (0)