Skip to content

Commit

Permalink
[zh-cn] sync configure-pod-container/*
Browse files Browse the repository at this point in the history
Signed-off-by: xin.li <xin.li@daocloud.io>
  • Loading branch information
my-git9 committed Sep 12, 2023
1 parent 224572c commit da025ec
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 51 deletions.
Expand Up @@ -102,7 +102,7 @@ Kubernetes 提供了存活探针来发现并处理这种情况。
在本练习中,你会创建一个 Pod,其中运行一个基于 `registry.k8s.io/busybox` 镜像的容器。
下面是这个 Pod 的配置文件。

{{% code file="pods/probe/exec-liveness.yaml" %}}
{{% code_sample file="pods/probe/exec-liveness.yaml" %}}

<!--
In the configuration file, you can see that the Pod has a single `Container`.
Expand Down Expand Up @@ -229,7 +229,7 @@ file for a Pod that runs a container based on the `registry.k8s.io/liveness` ima
另外一种类型的存活探测方式是使用 HTTP GET 请求。
下面是一个 Pod 的配置文件,其中运行一个基于 `registry.k8s.io/liveness` 镜像的容器。

{{% code file="pods/probe/http-liveness.yaml" %}}
{{% code_sample file="pods/probe/http-liveness.yaml" %}}

<!--
In the configuration file, you can see that the Pod has a single container.
Expand Down Expand Up @@ -325,7 +325,7 @@ can't it is considered a failure.
使用这种配置时,kubelet 会尝试在指定端口和容器建立套接字链接。
如果能建立连接,这个容器就被看作是健康的,如果不能则这个容器就被看作是有问题的。

{{% code file="pods/probe/tcp-liveness-readiness.yaml" %}}
{{% code_sample file="pods/probe/tcp-liveness-readiness.yaml" %}}

<!--
As you can see, configuration for a TCP check is quite similar to an HTTP check.
Expand Down Expand Up @@ -393,7 +393,7 @@ kubelet 可以配置为使用该协议来执行应用存活性检查。

下面是一个示例清单:

{{% code file="pods/probe/grpc-liveness.yaml" %}}
{{% code_sample file="pods/probe/grpc-liveness.yaml" %}}

<!--
To use a gRPC probe, `port` must be configured. If you want to distinguish probes of different types
Expand Down
Expand Up @@ -161,7 +161,7 @@ Here is the configuration file for the hostPath PersistentVolume:

下面是 hostPath PersistentVolume 的配置文件:

{{% code file="pods/storage/pv-volume.yaml" %}}
{{% code_sample file="pods/storage/pv-volume.yaml" %}}

<!--
The configuration file specifies that the volume is at `/mnt/data` on the
Expand Down Expand Up @@ -227,7 +227,7 @@ Pod 使用 PersistentVolumeClaim 来请求物理存储。

下面是 PersistentVolumeClaim 的配置文件:

{{% code file="pods/storage/pv-claim.yaml" %}}
{{% code_sample file="pods/storage/pv-claim.yaml" %}}

<!--
Create the PersistentVolumeClaim:
Expand Down Expand Up @@ -299,7 +299,7 @@ Here is the configuration file for the Pod:

下面是此 Pod 的配置文件:

{{% code file="pods/storage/pv-pod.yaml" %}}
{{% code_sample file="pods/storage/pv-pod.yaml" %}}

<!--
Notice that the Pod's configuration file specifies a PersistentVolumeClaim, but
Expand Down Expand Up @@ -414,7 +414,7 @@ You can now close the shell to your Node.
-->
## 在两个地方挂载相同的 persistentVolume {#mounting-the-same-pv-in-two-places}

{{% code file="pods/storage/pv-duplicate.yaml" %}}
{{% code_sample file="pods/storage/pv-duplicate.yaml" %}}

<!--
You can perform 2 volume mounts on your nginx container:
Expand Down
Expand Up @@ -788,7 +788,7 @@ section, and learn how to use these objects with Pods.
-->
2. 将 ConfigMap 中定义的 `special.how` 赋值给 Pod 规约中的 `SPECIAL_LEVEL_KEY` 环境变量。
{{% code file="pods/pod-single-configmap-env-variable.yaml" %}}
{{% code_sample file="pods/pod-single-configmap-env-variable.yaml" %}}
<!--
Create the Pod:
Expand Down Expand Up @@ -816,7 +816,7 @@ Here is the manifest you will use:
与前面的示例一样,首先创建 ConfigMap。
这是你将使用的清单:

{{% code file="configmap/configmaps.yaml" %}}
{{% code_sample file="configmap/configmaps.yaml" %}}

<!--
* Create the ConfigMap:
Expand All @@ -832,7 +832,7 @@ Here is the manifest you will use:
-->
* 在 Pod 规约中定义环境变量。

{{% code file="pods/pod-multiple-configmap-env-variable.yaml" %}}
{{% code_sample file="pods/pod-multiple-configmap-env-variable.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -867,7 +867,7 @@ Here is the manifest you will use:
-->
* 创建一个包含多个键值对的 ConfigMap。

{{% code file="configmap/configmap-multikeys.yaml" %}}
{{% code_sample file="configmap/configmap-multikeys.yaml" %}}

<!--
Create the ConfigMap:
Expand All @@ -885,7 +885,7 @@ Here is the manifest you will use:
* 使用 `envFrom` 将所有 ConfigMap 的数据定义为容器环境变量,ConfigMap
中的键成为 Pod 中的环境变量名称。
{{% code file="pods/pod-configmap-envFrom.yaml" %}}
{{% code_sample file="pods/pod-configmap-envFrom.yaml" %}}
<!--
Create the Pod:
Expand Down Expand Up @@ -928,7 +928,7 @@ For example, the following Pod manifest:
-->
例如,以下 Pod 清单:
{{% code file="pods/pod-configmap-env-var-valueFrom.yaml" %}}
{{% code_sample file="pods/pod-configmap-env-var-valueFrom.yaml" %}}
<!--
Create that Pod, by running:
Expand Down Expand Up @@ -978,7 +978,7 @@ The examples in this section refer to a ConfigMap named `special-config`:
-->
本节中的示例引用了一个名为 `special-config` 的 ConfigMap:
{{% code file="configmap/configmap-multikeys.yaml" %}}
{{% code_sample file="configmap/configmap-multikeys.yaml" %}}
<!--
Create the ConfigMap:
Expand All @@ -1004,7 +1004,7 @@ keys in ConfigMap.
(在本例中为 `/etc/config`)。
`command` 部分列出了名称与 ConfigMap 中的键匹配的目录文件。
{{% code file="pods/pod-configmap-volume.yaml" %}}
{{% code_sample file="pods/pod-configmap-volume.yaml" %}}
<!--
Create the Pod:
Expand Down Expand Up @@ -1063,7 +1063,7 @@ In this case, the `SPECIAL_LEVEL` item will be mounted in the `config-volume` vo
在这里,ConfigMap 中键 `SPECIAL_LEVEL` 的内容将挂载在 `config-volume`
卷中 `/etc/config/keys` 文件中。

{{% code file="pods/pod-configmap-volume-specific-key.yaml" %}}
{{% code_sample file="pods/pod-configmap-volume-specific-key.yaml" %}}

<!--
Create the Pod:
Expand Down
Expand Up @@ -38,7 +38,7 @@ Here is the configuration file for the Pod:

下面是 Pod 的配置文件:

{{% code file="pods/init-containers.yaml" %}}
{{% code_sample file="pods/init-containers.yaml" %}}

<!--
In the configuration file, you can see that the Pod has a Volume that the init
Expand Down
Expand Up @@ -54,7 +54,7 @@ Here is a configuration file for a Windows Pod that has the `runAsUserName` fiel

这儿有一个已经设置了 `runAsUserName` 字段的 Windows Pod 的配置文件:

{{% code file="windows/run-as-username-pod.yaml" %}}
{{% code_sample file="windows/run-as-username-pod.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -134,7 +134,7 @@ Here is the configuration file for a Pod that has one Container, and the `runAsU

这里有一个 Pod 的配置文件,其中只有一个容器,并且在 Pod 级别和容器级别都设置了 `runAsUserName`

{{% code file="windows/run-as-username-container.yaml" %}}
{{% code_sample file="windows/run-as-username-container.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -184,7 +184,9 @@ ContainerAdministrator
<!--
## Windows Username limitations
In order to use this feature, the value set in the `runAsUserName` field must be a valid username. It must have the following format: `DOMAIN\USER`, where `DOMAIN\` is optional. Windows user names are case insensitive. Additionally, there are some restrictions regarding the `DOMAIN` and `USER`:
In order to use this feature, the value set in the `runAsUserName` field must be a valid username.
It must have the following format: `DOMAIN\USER`, where `DOMAIN\` is optional. Windows user names
are case insensitive. Additionally, there are some restrictions regarding the `DOMAIN` and `USER`:
-->
## Windows Username 的局限性 {#windows-username-limitations}

Expand All @@ -203,7 +205,7 @@ Windows 用户名不区分大小写。此外,关于 `DOMAIN` 和 `USER` 还有
- `DOMAIN` 必须是 NetBios 名称或 DNS 名称,每种名称都有各自的局限性:
- NetBios 名称:最多 15 个字符,不能以 `.`(点)开头,并且不能包含以下字符:`\ / : * ? " < > |`
- DNS 名称:最多 255 个字符,只能包含字母、数字、点和中划线,并且不能以 `.`(点)或 `-`(中划线)开头和结尾。
- `USER` 最多不超过 20 个字符,不能 **** 包含点或空格,并且不能包含以下字符:`" / \ [ ] : ; | = , + * ? < > @`
- `USER` 最多不超过 20 个字符,不能****包含点或空格,并且不能包含以下字符:`" / \ [ ] : ; | = , + * ? < > @`

<!--
Examples of acceptable values for the `runAsUserName` field: `ContainerAdministrator`, `ContainerUser`, `NT AUTHORITY\NETWORK SERVICE`, `NT AUTHORITY\LOCAL SERVICE`.
Expand All @@ -224,4 +226,4 @@ For more information about these limtations, check [here](https://support.micros
-->
* [Kubernetes 中调度 Windows 容器的指南](/zh-cn/docs/concepts/windows/user-guide/)
* [使用组托管服务帐户(GMSA)管理工作负载身份](/zh-cn/docs/concepts/windows/user-guide/#managing-workload-identity-with-group-managed-service-accounts)
* [Windows 下 pod 和容器的 GMSA 配置](/zh-cn/docs/tasks/configure-pod-container/configure-gmsa/)
* [Windows 下 Pod 和容器的 GMSA 配置](/zh-cn/docs/tasks/configure-pod-container/configure-gmsa/)
Expand Up @@ -83,16 +83,15 @@ kubectl get pods/<podname> -o yaml

<!--
In the output, you see a field `spec.serviceAccountName`.
Kubernetes [automatically](/docs/concepts/overview/working-with-objects/object-management/)
Kubernetes automatically
sets that value if you don't specify it when you create a Pod.
An application running inside a Pod can access the Kubernetes API using
automatically mounted service account credentials.
See [accessing the Cluster](/docs/tasks/access-application-cluster/access-cluster/) to learn more.
-->
在输出中,你可以看到字段 `spec.serviceAccountName`。当你在创建 Pod 时未设置该字段时,
Kubernetes [自动](/zh-cn/docs/concepts/overview/working-with-objects/object-management/)
Pod 设置这一属性的取值。
Kubernetes 自动为 Pod 设置这一属性的取值。

Pod 中运行的应用可以使用这一自动挂载的服务账号凭据来访问 Kubernetes API。
参阅[访问集群](/zh-cn/docs/tasks/access-application-cluster/access-cluster/)以进一步了解。
Expand Down Expand Up @@ -657,7 +656,7 @@ of two hours, you could define a Pod manifest that is similar to:
要为某 Pod 提供一个受众为 `vault` 并且有效期限为 2 小时的令牌,你可以定义一个与下面类似的
Pod 清单:

{{% code file="pods/pod-projected-svc-token.yaml" %}}
{{% code_sample file="pods/pod-projected-svc-token.yaml" %}}

<!--
Create the Pod:
Expand Down
Expand Up @@ -46,7 +46,7 @@ restarts. Here is the configuration file for the Pod:
[emptyDir](/zh-cn/docs/concepts/storage/volumes/#emptydir) 的卷,
在整个 Pod 生命周期中一直存在,即使 Pod 中的容器被终止和重启。以下是 Pod 的配置:

{{% code file="pods/storage/redis.yaml" %}}
{{% code_sample file="pods/storage/redis.yaml" %}}

<!--
1. Create the Pod:
Expand Down
Expand Up @@ -54,7 +54,7 @@ Here is the configuration file for a Pod that has one Container:

下面是包含一个容器的 Pod 配置文件:

{{% code file="pods/resource/extended-resource-pod.yaml" %}}
{{% code_sample file="pods/resource/extended-resource-pod.yaml" %}}

<!--
In the configuration file, you can see that the Container requests 3 dongles.
Expand Down Expand Up @@ -109,7 +109,7 @@ two dongles.

下面是包含一个容器的 Pod 配置文件,容器请求了 2 个 dongles。

{{% code file="pods/resource/extended-resource-pod-2.yaml" %}}
{{% code_sample file="pods/resource/extended-resource-pod-2.yaml" %}}

<!--
Kubernetes will not be able to satisfy the request for two dongles, because the first Pod
Expand Down
Expand Up @@ -313,7 +313,7 @@ Here is a manifest for an example Pod that needs access to your Docker credentia

下面是一个 Pod 配置清单示例,该示例中 Pod 需要访问你的 Docker 凭据 `regcred`

{{% code file="pods/private-reg-pod.yaml" %}}
{{% code_sample file="pods/private-reg-pod.yaml" %}}

<!--
Download the above file onto your computer:
Expand Down
Expand Up @@ -95,7 +95,7 @@ memory request, both equal to 200 MiB. The Container has a CPU limit and a CPU r
下面是包含一个 Container 的 Pod 清单。该 Container 设置了内存请求和内存限制,值都是 200 MiB。
该 Container 设置了 CPU 请求和 CPU 限制,值都是 700 milliCPU:

{{% code file="pods/qos/qos-pod.yaml" %}}
{{% code_sample file="pods/qos/qos-pod.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -186,7 +186,7 @@ and a memory request of 100 MiB.
下面是包含一个 Container 的 Pod 清单。该 Container 设置的内存限制为 200 MiB,
内存请求为 100 MiB。

{{% code file="pods/qos/qos-pod-2.yaml" %}}
{{% code_sample file="pods/qos/qos-pod-2.yaml" %}}

<!--
Create the Pod:
Expand All @@ -209,7 +209,7 @@ kubectl get pod qos-demo-2 --namespace=qos-example --output=yaml
<!--
The output shows that Kubernetes gave the Pod a QoS class of `Burstable`:
-->
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 `Burstable`
结果表明 Kubernetes 为 Pod 配置的 QoS 类为 `Burstable`

```yaml
spec:
Expand Down Expand Up @@ -256,7 +256,7 @@ limits or requests:

下面是包含一个 Container 的 Pod 清单。该 Container 没有设置内存和 CPU 限制或请求。

{{% code file="pods/qos/qos-pod-3.yaml" %}}
{{% code_sample file="pods/qos/qos-pod-3.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -316,7 +316,7 @@ request of 200 MiB. The other Container does not specify any requests or limits.
下面是包含两个 Container 的 Pod 清单。一个 Container 指定内存请求为 200 MiB。
另外一个 Container 没有指定任何请求或限制。

{{% code file="pods/qos/qos-pod-4.yaml" %}}
{{% code_sample file="pods/qos/qos-pod-4.yaml" %}}

<!--
Notice that this Pod meets the criteria for QoS class `Burstable`. That is, it does not meet the
Expand Down
Expand Up @@ -166,7 +166,7 @@ Consider the following manifest for a Pod that has one Container.

考虑以下包含一个容器的 Pod 的清单。

{{% code file="pods/qos/qos-pod-5.yaml" %}}
{{% code_sample file="pods/qos/qos-pod-5.yaml" %}}

<!--
Create the pod in the `qos-example` namespace:
Expand Down
Expand Up @@ -108,7 +108,7 @@ Here is a configuration file for a Pod that has a `securityContext` and an `empt
对象。你为 Pod 所设置的安全性配置会应用到 Pod 中所有 Container 上。
下面是一个 Pod 的配置文件,该 Pod 定义了 `securityContext` 和一个 `emptyDir` 卷:

{{% code file="pods/security/security-context.yaml" %}}
{{% code_sample file="pods/security/security-context.yaml" %}}

<!--
In the configuration file, the `runAsUser` field specifies that for any Containers in
Expand Down Expand Up @@ -371,7 +371,7 @@ Pod 层面设置的内容发生重叠时,会重写 Pod 层面的设置。Conta
下面是一个 Pod 的配置文件,其中包含一个 Container。Pod 和 Container 都有
`securityContext` 字段:

{{% code file="pods/security/security-context-2.yaml" %}}
{{% code_sample file="pods/security/security-context-2.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -454,7 +454,7 @@ Here is configuration file that does not add or remove any Container capabilitie
首先,看一下不包含 `capabilities` 字段时候会发生什么。
下面是一个配置文件,其中没有添加或移除容器的权能:

{{% code file="pods/security/security-context-3.yaml" %}}
{{% code_sample file="pods/security/security-context-3.yaml" %}}

<!--
Create the Pod:
Expand Down Expand Up @@ -546,7 +546,7 @@ adds the `CAP_NET_ADMIN` and `CAP_SYS_TIME` capabilities:
下面是一个 Pod 的配置,其中运行一个容器。配置为容器添加 `CAP_NET_ADMIN`
`CAP_SYS_TIME` 权能:

{{% code file="pods/security/security-context-4.yaml" %}}
{{% code_sample file="pods/security/security-context-4.yaml" %}}

<!--
Create the Pod:
Expand Down
Expand Up @@ -50,7 +50,7 @@ Process namespace sharing is enabled using the `shareProcessNamespace` field of
-->
使用 Pod `.spec` 中的 `shareProcessNamespace` 字段可以启用进程命名空间共享。例如:

{{% code file="pods/share-process-namespace.yaml" %}}
{{% code_sample file="pods/share-process-namespace.yaml" %}}

<!--
1. Create the pod `nginx` on your cluster:
Expand Down Expand Up @@ -208,4 +208,3 @@ Pod 共享许多资源,因此它们共享进程命名空间是很有意义的
-->
3. **容器文件系统通过 `/proc/$pid/root` 链接对 Pod 中的其他容器可见。** 这使调试更加容易,
但也意味着文件系统安全性只受文件系统权限的保护。

0 comments on commit da025ec

Please sign in to comment.