diff --git a/content/zh/docs/tasks/configure-pod-container/assign-cpu-resource.md b/content/zh/docs/tasks/configure-pod-container/assign-cpu-resource.md index cc8d90cc88..df1636c8dd 100644 --- a/content/zh/docs/tasks/configure-pod-container/assign-cpu-resource.md +++ b/content/zh/docs/tasks/configure-pod-container/assign-cpu-resource.md @@ -166,9 +166,9 @@ kubectl top pod cpu-demo --namespace=cpu-example -此示例输出显示 Pod 使用的是 974 milliCPU,即仅略低于 Pod 配置中指定的 1 个 CPU 的限制。 +此示例输出显示 Pod 使用的是 974 milliCPU,即略低于 Pod 配置中指定的 1 个 CPU 的限制。 ``` NAME CPU(cores) MEMORY(bytes) diff --git a/content/zh/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes.md b/content/zh/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes.md index a55821b51f..7355e5c11e 100644 --- a/content/zh/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes.md +++ b/content/zh/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes.md @@ -8,10 +8,10 @@ weight: 110 这篇文章介绍如何给容器配置存活、就绪和启动探测器。 @@ -22,12 +22,12 @@ despite bugs. 这样的情况下重启容器有助于让应用程序在有问题的情况下更可用。 @@ -56,7 +56,7 @@ Many applications running for long periods of time eventually transition to broken states, and cannot recover except by being restarted. Kubernetes provides liveness probes to detect and remedy such situations. -In this exercise, you create a Pod that runs a Container based on the +In this exercise, you create a Pod that runs a container based on the `k8s.gcr.io/busybox` image. Here is the configuration file for the Pod: --> ## 定义存活命令 {#define-a-liveness-command} @@ -70,16 +70,16 @@ Kubernetes 提供了存活探测器来发现并补救这种情况。 {{< codenew file="pods/probe/exec-liveness.yaml" >}} 在这个配置文件中,可以看到 Pod 中只有一个容器。 `periodSeconds` 字段指定了 kubelet 应该每 5 秒执行一次存活探测。 @@ -95,7 +95,7 @@ kubelet 在容器内执行命令 `cat /tmp/healthy` 来进行探测。 ``` 在这个配置文件中,可以看到 Pod 也只有一个容器。 @@ -217,14 +217,14 @@ Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure. You can see the source code for the server in -[server.go](https://github.com/kubernetes/kubernetes/blob/master/test/images/agnhost/liveness/server.go). +[server.go](https://github.com/kubernetes/kubernetes/blob/{{< param "githubbranch" >}}/test/images/agnhost/liveness/server.go). -For the first 10 seconds that the Container is alive, the `/healthz` handler +For the first 10 seconds that the container is alive, the `/healthz` handler returns a status of 200. After that, the handler returns a status of 500. --> 任何大于或等于 200 并且小于 400 的返回代码标示成功,其它返回代码都标示失败。 -可以在这里看服务的源码 [server.go](https://github.com/kubernetes/kubernetes/blob/master/test/images/agnhost/liveness/server.go)。 +可以在这里看服务的源码 [server.go](https://github.com/kubernetes/kubernetes/blob/{{< param "githubbranch" >}}/test/images/agnhost/liveness/server.go)。 容器存活的最开始 10 秒中,`/healthz` 处理程序返回一个 200 的状态码。之后处理程序返回 500 的状态码。 @@ -242,9 +242,9 @@ http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { ``` @@ -259,7 +259,7 @@ kubectl apply -f https://k8s.io/examples/pods/probe/http-liveness.yaml 10 秒之后,通过看 Pod 事件来检测存活探测器已经失败了并且容器被重新启动了。 @@ -269,7 +269,7 @@ kubectl describe pod liveness-http +{{< caution >}} +活跃性探测器 *不等待* 就绪性探测器成功。 +如果要在执行活跃性探测器之前等待,应该使用 initialDelaySeconds 或 startupProbe。 +{{< /caution >}} + +### 探测器级别 `terminationGracePeriodSeconds` + +{{< feature-state for_k8s_version="v1.21" state="alpha" >}} + + +在 1.21 版之前,pod 级别的 `terminationGracePeriodSeconds` 被用来终止 +未能成功处理活跃性探测或启动探测的容器。 +这种耦合是意料之外的,可能会导致在设置了 pod 级别的 `terminationGracePeriodSeconds` 后, +需要很长的时间来重新启动失败的容器。 + + +在1.21中,启用特性标志 `ProbeTerminationGracePeriod` 后, +用户可以指定一个探测器级别的 `terminationGracePeriodSeconds` 作为探测器规格的一部分。 +当该特性标志被启用时,若同时设置了 Pod 级别和探测器级别的 `terminationGracePeriodSeconds`, +kubelet 将使用探测器级的值。 + +例如, + +```yaml +spec: + terminationGracePeriodSeconds: 3600 # pod-level + containers: + - name: test + image: ... + + ports: + - name: liveness-port + containerPort: 8080 + hostPort: 8080 + + livenessProbe: + httpGet: + path: /healthz + port: liveness-port + failureThreshold: 1 + periodSeconds: 60 + # Override pod-level terminationGracePeriodSeconds # + terminationGracePeriodSeconds: 60 +``` + + +探测器级别的 `terminationGracePeriodSeconds` 不能用于设置就绪态探针。 +它将被 API 服务器拒绝。 + ## {{% heading "whatsnext" %}} -### 参考 {#reference} +你也可以阅读以下的 API 参考资料: * [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core) * [Container](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#container-v1-core) diff --git a/content/zh/docs/tasks/configure-pod-container/static-pod.md b/content/zh/docs/tasks/configure-pod-container/static-pod.md index 582e94616d..a202caf1b5 100644 --- a/content/zh/docs/tasks/configure-pod-container/static-pod.md +++ b/content/zh/docs/tasks/configure-pod-container/static-pod.md @@ -27,6 +27,7 @@ The kubelet automatically tries to create a {{< glossary_tooltip text="mirror Po on the Kubernetes API server for each static Pod. This means that the Pods running on a node are visible on the API server, but cannot be controlled from there. +The Pod names will suffixed with the node hostname with a leading hyphen {{< note >}} If you are running clustered Kubernetes and are using static @@ -40,6 +41,7 @@ instead. kubelet 会尝试通过 Kubernetes API 服务器为每个静态 Pod 自动创建一个 {{< glossary_tooltip text="镜像 Pod" term_id="mirror-pod" >}}。 这意味着节点上运行的静态 Pod 对 API 服务来说是可见的,但是不能通过 API 服务器来控制。 +Pod 名称将把以连字符开头的节点主机名作为后缀。 {{< note >}} 如果你在运行一个 Kubernetes 集群,并且在每个节点上都运行一个静态 Pod, @@ -48,7 +50,6 @@ kubelet 会尝试通过 Kubernetes API 服务器为每个静态 Pod 自动创建 ## {{% heading "prerequisites" %}} - {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} 3. 配置这个节点上的 kubelet,使用这个参数执行 `--pod-manifest-path=/etc/kubelet.d/`。 在 Fedora 上编辑 `/etc/kubernetes/kubelet` 以包含下行: @@ -161,16 +165,16 @@ For example, this is how to start a simple web server as a static Pod: ``` KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubelet.d/" ``` - 或者在 [Kubelet配置文件](/zh/docs/tasks/administer-cluster/kubelet-config-file/) + 或者在 [Kubelet 配置文件](/zh/docs/reference/config-api/kubelet-config.v1beta1/) 中添加 `staticPodPath: <目录>`字段。 4. 重启 kubelet。Fedora 上使用下面的命令: diff --git a/content/zh/docs/tasks/configure-pod-container/translate-compose-kubernetes.md b/content/zh/docs/tasks/configure-pod-container/translate-compose-kubernetes.md index 23577048b2..8c5bb67da5 100644 --- a/content/zh/docs/tasks/configure-pod-container/translate-compose-kubernetes.md +++ b/content/zh/docs/tasks/configure-pod-container/translate-compose-kubernetes.md @@ -106,7 +106,7 @@ sudo yum -y install kompose {{% tab name="Fedora package" %}} Kompose 位于 Fedora 24、25 和 26 的代码仓库。你可以像安装其他软件包一样安装 Kompose。 @@ -135,7 +135,7 @@ brew install kompose ## 使用 Kompose 再需几步,我们就把你从 Docker Compose 带到 Kubernetes。