[zh] Fix links in concepts section (6)
This commit is contained in:
@@ -3,6 +3,14 @@ title: 容器环境
|
||||
content_type: concept
|
||||
weight: 20
|
||||
---
|
||||
<!--
|
||||
reviewers:
|
||||
- mikedanese
|
||||
- thockin
|
||||
title: Container Environment
|
||||
content_type: concept
|
||||
weight: 20
|
||||
-->
|
||||
|
||||
<!-- overview -->
|
||||
|
||||
@@ -11,9 +19,6 @@ This page describes the resources available to Containers in the Container envir
|
||||
-->
|
||||
本页描述了在容器环境里容器可用的资源。
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- body -->
|
||||
|
||||
<!--
|
||||
@@ -25,13 +30,14 @@ The Kubernetes Container environment provides several important resources to Con
|
||||
* Information about the Container itself.
|
||||
* Information about other objects in the cluster.
|
||||
-->
|
||||
## 容器环境
|
||||
## 容器环境 {#container-environment}
|
||||
|
||||
Kubernetes 的容器环境给容器提供了几个重要的资源:
|
||||
|
||||
* 文件系统,其中包含一个[镜像](/docs/concepts/containers/images/) 和一个或多个的[卷](/docs/concepts/storage/volumes/)。
|
||||
* 容器自身的信息。
|
||||
* 集群中其他对象的信息。
|
||||
* 文件系统,其中包含一个[镜像](/zh/docs/concepts/containers/images/)
|
||||
和一个或多个的[卷](/zh/docs/concepts/storage/volumes/)
|
||||
* 容器自身的信息
|
||||
* 集群中其他对象的信息
|
||||
|
||||
<!--
|
||||
### Container information
|
||||
@@ -49,9 +55,12 @@ as are any environment variables specified statically in the Docker image.
|
||||
-->
|
||||
### 容器信息
|
||||
|
||||
容器的 *hostname* 是它所运行在的 pod 的名称。它可以通过 `hostname` 命令或者调用 libc 中的 [`gethostname`](http://man7.org/linux/man-pages/man2/gethostname.2.html) 函数来获取。
|
||||
容器的 *hostname* 是它所运行在的 pod 的名称。它可以通过 `hostname` 命令或者调用 libc 中的
|
||||
[`gethostname`](https://man7.org/linux/man-pages/man2/gethostname.2.html) 函数来获取。
|
||||
|
||||
Pod 名称和命名空间可以通过 [downward API](/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/) 使用环境变量。
|
||||
Pod 名称和命名空间可以通过
|
||||
[下行 API](/zh/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/)
|
||||
转换为环境变量。
|
||||
|
||||
Pod 定义中的用户所定义的环境变量也可在容器中使用,就像在 Docker 镜像中静态指定的任何环境变量一样。
|
||||
|
||||
@@ -79,19 +88,18 @@ FOO_SERVICE_PORT=<the port the service is running on>
|
||||
Services have dedicated IP addresses and are available to the Container via DNS,
|
||||
if [DNS addon](http://releases.k8s.io/{{< param "githubbranch" >}}/cluster/addons/dns/) is enabled.
|
||||
-->
|
||||
Service 具有专用的 IP 地址。如果启用了 [DNS插件](http://releases.k8s.io/{{< param "githubbranch" >}}/cluster/addons/dns/),就可以在容器中通过 DNS 来访问。
|
||||
|
||||
|
||||
服务具有专用的 IP 地址。如果启用了
|
||||
[DNS插件](https://releases.k8s.io/{{< param "githubbranch" >}}/cluster/addons/dns/),
|
||||
可以在容器中通过 DNS 来访问服务。
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
|
||||
<!--
|
||||
* Learn more about [Container lifecycle hooks](/docs/concepts/containers/container-lifecycle-hooks/).
|
||||
* Get hands-on experience
|
||||
[attaching handlers to Container lifecycle events](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/).
|
||||
-->
|
||||
* 学习更多有关[容器生命周期钩子](/docs/concepts/containers/container-lifecycle-hooks/)的知识。
|
||||
* 动手获得经验[将处理程序附加到容器生命周期事件](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)。
|
||||
* 学习更多有关[容器生命周期回调](/zh/docs/concepts/containers/container-lifecycle-hooks/)的知识
|
||||
* 动手[为容器生命周期事件添加处理程序](/zh/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
---
|
||||
reviewers:
|
||||
- mikedanese
|
||||
- thockin
|
||||
title: 容器生命周期钩子
|
||||
title: 容器生命周期回调
|
||||
content_type: concept
|
||||
weight: 30
|
||||
---
|
||||
|
||||
<!--
|
||||
reviewers:
|
||||
- mikedanese
|
||||
@@ -16,45 +12,38 @@ content_type: concept
|
||||
weight: 30
|
||||
-->
|
||||
|
||||
|
||||
<!-- overview -->
|
||||
|
||||
<!--
|
||||
This page describes how kubelet managed Containers can use the Container lifecycle hook framework
|
||||
to run code triggered by events during their management lifecycle.
|
||||
-->
|
||||
这个页面描述了 kubelet 管理的容器如何使用容器生命周期钩子框架来运行在其管理生命周期中由事件触发的代码。
|
||||
|
||||
|
||||
|
||||
这个页面描述了 kubelet 管理的容器如何使用容器生命周期回调框架,
|
||||
藉由其管理生命周期中的事件触发,运行指定代码。
|
||||
|
||||
<!-- body -->
|
||||
|
||||
<!--
|
||||
## Overview
|
||||
-->
|
||||
|
||||
## 概述
|
||||
|
||||
<!--
|
||||
Analogous to many programming language frameworks that have component lifecycle hooks, such as Angular,
|
||||
Kubernetes provides Containers with lifecycle hooks.
|
||||
The hooks enable Containers to be aware of events in their management lifecycle
|
||||
and run code implemented in a handler when the corresponding lifecycle hook is executed.
|
||||
-->
|
||||
类似于许多具有生命周期钩子组件的编程语言框架,例如 Angular、Kubernetes 为容器提供了生命周期钩子。
|
||||
钩子使容器能够了解其管理生命周期中的事件,并在执行相应的生命周期钩子时运行在处理程序中实现的代码。
|
||||
## 概述
|
||||
|
||||
类似于许多具有生命周期回调组件的编程语言框架,例如 Angular、Kubernetes 为容器提供了生命周期回调。
|
||||
回调使容器能够了解其管理生命周期中的事件,并在执行相应的生命周期回调时运行在处理程序中实现的代码。
|
||||
|
||||
<!--
|
||||
## Container hooks
|
||||
-->
|
||||
|
||||
## 容器钩子
|
||||
|
||||
<!--
|
||||
There are two hooks that are exposed to Containers:
|
||||
-->
|
||||
有两个钩子暴露在容器中:
|
||||
## 容器回调
|
||||
|
||||
有两个回调暴露给容器:
|
||||
|
||||
`PostStart`
|
||||
|
||||
@@ -63,8 +52,8 @@ This hook executes immediately after a container is created.
|
||||
However, there is no guarantee that the hook will execute before the container ENTRYPOINT.
|
||||
No parameters are passed to the handler.
|
||||
-->
|
||||
这个钩子在创建容器之后立即执行。
|
||||
但是,不能保证钩子会在容器入口点之前执行。
|
||||
这个回调在创建容器之后立即执行。
|
||||
但是,不能保证回调会在容器入口点(ENTRYPOINT)之前执行。
|
||||
没有参数传递给处理程序。
|
||||
|
||||
`PreStop`
|
||||
@@ -75,29 +64,29 @@ It is blocking, meaning it is synchronous,
|
||||
so it must complete before the call to delete the container can be sent.
|
||||
No parameters are passed to the handler.
|
||||
-->
|
||||
|
||||
在容器终止之前是否立即调用此钩子,取决于 API 的请求或者管理事件,类似活动探针故障、资源抢占、资源竞争等等。 如果容器已经完全处于终止或者完成状态,则对 preStop 钩子的调用将失败。
|
||||
它是阻塞的,同时也是同步的,因此它必须在删除容器的调用之前完成。
|
||||
在容器因 API 请求或者管理事件(诸如存活态探针失败、资源抢占、资源竞争等)而被终止之前,
|
||||
此回调会被调用。
|
||||
如果容器已经处于终止或者完成状态,则对 preStop 回调的调用将失败。
|
||||
此调用是阻塞的,也是同步调用,因此必须在删除容器的调用之前完成。
|
||||
没有参数传递给处理程序。
|
||||
|
||||
<!--
|
||||
A more detailed description of the termination behavior can be found in
|
||||
[Termination of Pods](/docs/concepts/workloads/pods/pod/#termination-of-pods).
|
||||
[Termination of Pods](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination).
|
||||
-->
|
||||
有关终止行为的更详细描述,请参见[终止 Pod](/docs/concepts/workloads/pods/pod/#termination-of-pods)。
|
||||
有关终止行为的更详细描述,请参见
|
||||
[终止 Pod](/zh/docs/concepts/workloads/pods/pod-lifecycle/#termination-of-pods)。
|
||||
|
||||
<!--
|
||||
### Hook handler implementations
|
||||
-->
|
||||
|
||||
### 钩子处理程序的实现
|
||||
|
||||
<!--
|
||||
Containers can access a hook by implementing and registering a handler for that hook.
|
||||
There are two types of hook handlers that can be implemented for Containers:
|
||||
-->
|
||||
容器可以通过实现和注册该钩子的处理程序来访问该钩子。
|
||||
针对容器,有两种类型的钩子处理程序可供实现:
|
||||
### 回调处理程序的实现
|
||||
|
||||
容器可以通过实现和注册该回调的处理程序来访问该回调。
|
||||
针对容器,有两种类型的回调处理程序可供实现:
|
||||
|
||||
<!--
|
||||
* Exec - Executes a specific command, such as `pre-stop.sh`, inside the cgroups and namespaces of the Container.
|
||||
@@ -105,21 +94,19 @@ Resources consumed by the command are counted against the Container.
|
||||
* HTTP - Executes an HTTP request against a specific endpoint on the Container.
|
||||
-->
|
||||
|
||||
* Exec - 执行一个特定的命令,例如 `pre-stop.sh`,在容器的 cgroups 和名称空间中。
|
||||
命令所消耗的资源根据容器进行计算。
|
||||
* Exec - 在容器的 cgroups 和名称空间中执行特定的命令(例如 `pre-stop.sh`)。
|
||||
命令所消耗的资源计入容器的资源消耗。
|
||||
* HTTP - 对容器上的特定端点执行 HTTP 请求。
|
||||
|
||||
<!--
|
||||
### Hook handler execution
|
||||
-->
|
||||
|
||||
### 钩子处理程序执行
|
||||
|
||||
<!--
|
||||
When a Container lifecycle management hook is called,
|
||||
the Kubernetes management system executes the handler in the Container registered for that hook.
|
||||
-->
|
||||
当调用容器生命周期管理钩子时,Kubernetes 管理系统在为该钩子注册的容器中执行处理程序。
|
||||
### 回调处理程序执行
|
||||
|
||||
当调用容器生命周期管理回调时,Kubernetes 管理系统在注册了回调的容器中执行处理程序。
|
||||
|
||||
<!--
|
||||
Hook handler calls are synchronous within the context of the Pod containing the Container.
|
||||
@@ -128,9 +115,9 @@ the Container ENTRYPOINT and hook fire asynchronously.
|
||||
However, if the hook takes too long to run or hangs,
|
||||
the Container cannot reach a `running` state.
|
||||
-->
|
||||
钩子处理程序调用在包含容器的 Pod 上下文中是同步的。
|
||||
这意味着对于 `PostStart` 钩子,容器入口点和钩子异步触发。
|
||||
但是,如果钩子运行或挂起的时间太长,则容器无法达到 `running` 状态。
|
||||
回调处理程序调用在包含容器的 Pod 上下文中是同步的。
|
||||
这意味着对于 `PostStart` 回调,容器入口点和回调异步触发。
|
||||
但是,如果回调运行或挂起的时间太长,则容器无法达到 `running` 状态。
|
||||
|
||||
<!--
|
||||
The behavior is similar for a `PreStop` hook.
|
||||
@@ -139,32 +126,31 @@ the Pod phase stays in a `Terminating` state and is killed after `terminationGra
|
||||
If a `PostStart` or `PreStop` hook fails,
|
||||
it kills the Container.
|
||||
-->
|
||||
行为与 `PreStop` 钩子的行为类似。
|
||||
如果钩子在执行过程中挂起,Pod 阶段将保持在 `Terminating` 状态,并在 Pod 结束的 `terminationGracePeriodSeconds` 之后被杀死。
|
||||
如果 `PostStart` 或 `PreStop` 钩子失败,它会杀死容器。
|
||||
行为与 `PreStop` 回调的行为类似。
|
||||
如果回调在执行过程中挂起,Pod 阶段将保持在 `Terminating` 状态,
|
||||
并在 Pod 结束的 `terminationGracePeriodSeconds` 之后被杀死。
|
||||
如果 `PostStart` 或 `PreStop` 回调失败,它会杀死容器。
|
||||
|
||||
<!--
|
||||
Users should make their hook handlers as lightweight as possible.
|
||||
There are cases, however, when long running commands make sense,
|
||||
such as when saving state prior to stopping a Container.
|
||||
-->
|
||||
用户应该使他们的钩子处理程序尽可能的轻量级。
|
||||
用户应该使他们的回调处理程序尽可能的轻量级。
|
||||
但也需要考虑长时间运行的命令也很有用的情况,比如在停止容器之前保存状态。
|
||||
|
||||
<!--
|
||||
### Hook delivery guarantees
|
||||
-->
|
||||
|
||||
### 钩子寄送保证
|
||||
|
||||
<!--
|
||||
Hook delivery is intended to be *at least once*,
|
||||
which means that a hook may be called multiple times for any given event,
|
||||
such as for `PostStart` or `PreStop`.
|
||||
It is up to the hook implementation to handle this correctly.
|
||||
-->
|
||||
钩子的寄送应该是 *至少一次*,这意味着对于任何给定的事件,例如 `PostStart` 或 `PreStop`,钩子可以被调用多次。
|
||||
如何正确处理,是钩子实现所要考虑的问题。
|
||||
### 回调寄送保证
|
||||
|
||||
回调的寄送应该是 *至少一次*,这意味着对于任何给定的事件,例如 `PostStart` 或 `PreStop`,回调可以被调用多次。
|
||||
如何正确处理,是回调实现所要考虑的问题。
|
||||
|
||||
<!--
|
||||
Generally, only single deliveries are made.
|
||||
@@ -175,17 +161,13 @@ For instance, if a kubelet restarts in the middle of sending a hook,
|
||||
the hook might be resent after the kubelet comes back up.
|
||||
-->
|
||||
通常情况下,只会进行单次寄送。
|
||||
例如,如果 HTTP 钩子接收器宕机,无法接收流量,则不会尝试重新发送。
|
||||
例如,如果 HTTP 回调接收器宕机,无法接收流量,则不会尝试重新发送。
|
||||
然而,偶尔也会发生重复寄送的可能。
|
||||
例如,如果 kubelet 在发送钩子的过程中重新启动,钩子可能会在 kubelet 恢复后重新发送。
|
||||
例如,如果 kubelet 在发送回调的过程中重新启动,回调可能会在 kubelet 恢复后重新发送。
|
||||
|
||||
<!--
|
||||
### Debugging Hook handlers
|
||||
-->
|
||||
|
||||
### 调试钩子处理程序
|
||||
|
||||
<!--
|
||||
The logs for a Hook handler are not exposed in Pod events.
|
||||
If a handler fails for some reason, it broadcasts an event.
|
||||
For `PostStart`, this is the `FailedPostStartHook` event,
|
||||
@@ -193,7 +175,9 @@ and for `PreStop`, this is the `FailedPreStopHook` event.
|
||||
You can see these events by running `kubectl describe pod <pod_name>`.
|
||||
Here is some example output of events from running this command:
|
||||
-->
|
||||
钩子处理程序的日志不会在 Pod 事件中公开。
|
||||
### 调试回调处理程序
|
||||
|
||||
回调处理程序的日志不会在 Pod 事件中公开。
|
||||
如果处理程序由于某种原因失败,它将播放一个事件。
|
||||
对于 `PostStart`,这是 `FailedPostStartHook` 事件,对于 `PreStop`,这是 `FailedPreStopHook` 事件。
|
||||
您可以通过运行 `kubectl describe pod <pod_name>` 命令来查看这些事件。
|
||||
@@ -214,18 +198,14 @@ Events:
|
||||
1m 22s 2 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Warning FailedPostStartHook
|
||||
```
|
||||
|
||||
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
|
||||
<!--
|
||||
* Learn more about the [Container environment](/docs/concepts/containers/container-environment-variables/).
|
||||
* Learn more about the [Container environment](/docs/concepts/containers/container-environment/).
|
||||
* Get hands-on experience
|
||||
[attaching handlers to Container lifecycle events](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/).
|
||||
-->
|
||||
|
||||
* 了解更多关于[容器环境](/docs/concepts/containers/container-environment-variables/)。
|
||||
* 获取实践经验[将处理程序附加到容器生命周期事件](/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)。
|
||||
|
||||
* 进一步了解[容器环境](/zh/docs/concepts/containers/container-environment/)
|
||||
* 动手实践,[为容器生命周期事件添加处理程序](/zh/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
---
|
||||
reviewers:
|
||||
- tallclair
|
||||
- dchen1107
|
||||
title: 容器运行时类(Runtime Class)
|
||||
content_type: concept
|
||||
weight: 20
|
||||
---
|
||||
<!--
|
||||
reviewers:
|
||||
- tallclair
|
||||
- dchen1107
|
||||
title: Runtime Class
|
||||
content_type: concept
|
||||
weight: 20
|
||||
-->
|
||||
|
||||
<!-- overview -->
|
||||
|
||||
@@ -13,26 +18,19 @@ weight: 20
|
||||
|
||||
<!--
|
||||
This page describes the RuntimeClass resource and runtime selection mechanism.
|
||||
-->
|
||||
本页面描述了 RuntimeClass 资源和运行时的选择机制。
|
||||
|
||||
<!--
|
||||
RuntimeClass is a feature for selecting the container runtime configuration. The container runtime
|
||||
configuration is used to run a Pod's containers.
|
||||
-->
|
||||
本页面描述了 RuntimeClass 资源和运行时的选择机制。
|
||||
|
||||
RuntimeClass 是一个用于选择容器运行时配置的特性,容器运行时配置用于运行 Pod 中的容器。
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- body -->
|
||||
|
||||
<!--
|
||||
## Motivation
|
||||
-->
|
||||
## 动机
|
||||
|
||||
<!--
|
||||
You can set a different RuntimeClass between different Pods to provide a balance of
|
||||
performance versus security. For example, if part of your workload deserves a high
|
||||
level of information security assurance, you might choose to schedule those Pods so
|
||||
@@ -40,37 +38,37 @@ that they run in a container runtime that uses hardware virtualization. You'd th
|
||||
benefit from the extra isolation of the alternative runtime, at the expense of some
|
||||
additional overhead.
|
||||
-->
|
||||
您可以在不同的 pod 之间设置不同的 RuntimeClass,以提供性能与安全性之间的平衡。
|
||||
例如,如果您的部分工作负载需要高级别的信息安全保证,那么您可以选择性地调度这些 pod,
|
||||
使它们在使用硬件虚拟化的容器运行时中运行。
|
||||
然后,您将从可选运行时的额外隔离中获益,代价是一些额外的开销。
|
||||
## 动机 {#motivation}
|
||||
|
||||
你可以在不同的 Pod 设置不同的 RuntimeClass,以提供性能与安全性之间的平衡。
|
||||
例如,如果你的部分工作负载需要高级别的信息安全保证,你可以决定在调度这些 Pod
|
||||
时尽量使它们在使用硬件虚拟化的容器运行时中运行。
|
||||
这样,你将从这些不同运行时所提供的额外隔离中获益,代价是一些额外的开销。
|
||||
|
||||
<!--
|
||||
You can also use RuntimeClass to run different Pods with the same container runtime
|
||||
but with different settings.
|
||||
-->
|
||||
您还可以使用 RuntimeClass 运行具有相同容器运行时但具有不同设置的pod。
|
||||
你还可以使用 RuntimeClass 运行具有相同容器运行时但具有不同设置的 Pod。
|
||||
|
||||
<!--
|
||||
## Setup
|
||||
-->
|
||||
## 设置
|
||||
|
||||
<!--
|
||||
Ensure the RuntimeClass feature gate is enabled (it is by default). See [Feature
|
||||
Gates](/docs/reference/command-line-tools-reference/feature-gates/) for an explanation of enabling
|
||||
feature gates. The `RuntimeClass` feature gate must be enabled on apiservers _and_ kubelets.
|
||||
-->
|
||||
## 设置 {#setup}
|
||||
|
||||
确保 RuntimeClass 特性开关处于开启状态(默认为开启状态)。
|
||||
关于特性开关的详细介绍,请查阅
|
||||
[Feature Gates](/docs/reference/command-line-tools-reference/feature-gates/)。
|
||||
`RuntimeClass` 特性开关必须在 apiserver 和 kubelet 同时开启。
|
||||
关于特性开关的详细介绍,请参阅
|
||||
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)。
|
||||
`RuntimeClass` 特性开关必须在 API 服务器和 kubelet 端同时开启。
|
||||
|
||||
<!--
|
||||
1. Configure the CRI implementation on nodes (runtime dependent)
|
||||
2. Create the corresponding RuntimeClass resources
|
||||
-->
|
||||
|
||||
1. 在节点上配置 CRI 的实现(取决于所选用的运行时)
|
||||
2. 创建相应的 RuntimeClass 资源
|
||||
|
||||
@@ -87,11 +85,12 @@ CRI implementation for how to configure.
|
||||
RuntimeClass 的配置依赖于 运行时接口(CRI)的实现。
|
||||
根据你使用的 CRI 实现,查阅相关的文档([下方](#cri-configuration))来了解如何配置。
|
||||
|
||||
{{< note >}}
|
||||
<!--
|
||||
RuntimeClass assumes a homogeneous node configuration across the cluster by default (which means
|
||||
that all nodes are configured the same way with respect to container runtimes). To support
|
||||
heterogenous node configurations, see [Scheduling](#scheduling) below.-->
|
||||
heterogenous node configurations, see [Scheduling](#scheduling) below.
|
||||
-->
|
||||
{{< note >}}
|
||||
RuntimeClass 假设集群中的节点配置是同构的(换言之,所有的节点在容器运行时方面的配置是相同的)。
|
||||
如果需要支持异构节点,配置方法请参阅下面的 [调度](#scheduling)。
|
||||
{{< /note >}}
|
||||
@@ -105,13 +104,12 @@ handler 必须符合 DNS-1123 命名规范(字母、数字、或 `-`)。
|
||||
|
||||
<!--
|
||||
### 2. Create the corresponding RuntimeClass resources
|
||||
-->
|
||||
### 2. 创建相应的 RuntimeClass 资源
|
||||
|
||||
<!--
|
||||
The configurations setup in step 1 should each have an associated `handler` name, which identifies
|
||||
the configuration. For each handler, create a corresponding RuntimeClass object.
|
||||
-->
|
||||
### 2. 创建相应的 RuntimeClass 资源
|
||||
|
||||
在上面步骤 1 中,每个配置都需要有一个用于标识配置的 `handler`。
|
||||
针对每个 handler 需要创建一个 RuntimeClass 对象。
|
||||
|
||||
@@ -123,31 +121,32 @@ RuntimeClass 资源当前只有两个重要的字段:RuntimeClass 名 (`metada
|
||||
对象定义如下所示:
|
||||
|
||||
```yaml
|
||||
apiVersion: node.k8s.io/v1beta1 # RuntimeClass is defined in the node.k8s.io API group
|
||||
apiVersion: node.k8s.io/v1beta1 # RuntimeClass 定义于 node.k8s.io API 组
|
||||
kind: RuntimeClass
|
||||
metadata:
|
||||
name: myclass # The name the RuntimeClass will be referenced by
|
||||
# RuntimeClass is a non-namespaced resource
|
||||
handler: myconfiguration # The name of the corresponding CRI configuration
|
||||
name: myclass # 用来引用 RuntimeClass 的名字
|
||||
# RuntimeClass 是一个集群层面的资源
|
||||
handler: myconfiguration # 对应的 CRI 配置的名称
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
<!--
|
||||
It is recommended that RuntimeClass write operations (create/update/patch/delete) be
|
||||
restricted to the cluster administrator. This is typically the default. See [Authorization
|
||||
Overview](/docs/reference/access-authn-authz/authorization/) for more details.-->建议将 RuntimeClass 写操作(create、update、patch 和 delete)限定于集群管理员使用。
|
||||
通常这是默认配置。参阅[授权概述](/docs/reference/access-authn-authz/authorization/)了解更多信息。
|
||||
Overview](/docs/reference/access-authn-authz/authorization/) for more details.
|
||||
-->
|
||||
{{< note >}}
|
||||
建议将 RuntimeClass 写操作(create、update、patch 和 delete)限定于集群管理员使用。
|
||||
通常这是默认配置。参阅[授权概述](/zh/docs/reference/access-authn-authz/authorization/)了解更多信息。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
## Usage
|
||||
-->
|
||||
## 使用说明
|
||||
|
||||
<!--
|
||||
Once RuntimeClasses are configured for the cluster, using them is very simple. Specify a
|
||||
`runtimeClassName` in the Pod spec. For example:
|
||||
-->
|
||||
## 使用说明 {#usage}
|
||||
|
||||
一旦完成集群中 RuntimeClasses 的配置,使用起来非常方便。
|
||||
在 Pod spec 中指定 `runtimeClassName` 即可。例如:
|
||||
|
||||
@@ -168,9 +167,11 @@ RuntimeClass does not exist, or the CRI cannot run the corresponding handler, th
|
||||
corresponding [event](/docs/tasks/debug-application-cluster/debug-application-introspection/) for an
|
||||
error message.
|
||||
-->
|
||||
这一设置会告诉 Kubelet 使用所指的 RuntimeClass 来运行该 pod。
|
||||
如果所指的 RuntimeClass 不存在或者 CRI 无法运行相应的 handler,那么 pod 将会进入 `Failed` 终止[阶段](/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase)。
|
||||
你可以查看相应的[事件](/docs/tasks/debug-application-cluster/debug-application-introspection/),获取出错信息。
|
||||
这一设置会告诉 kubelet 使用所指的 RuntimeClass 来运行该 pod。
|
||||
如果所指的 RuntimeClass 不存在或者 CRI 无法运行相应的 handler,
|
||||
那么 pod 将会进入 `Failed` 终止[阶段](/zh/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase)。
|
||||
你可以查看相应的[事件](/zh/docs/tasks/debug-application-cluster/debug-application-introspection/),
|
||||
获取出错信息。
|
||||
|
||||
<!--
|
||||
If no `runtimeClassName` is specified, the default RuntimeHandler will be used, which is equivalent
|
||||
@@ -180,20 +181,20 @@ to the behavior when the RuntimeClass feature is disabled.
|
||||
|
||||
<!--
|
||||
### CRI Configuration
|
||||
-->
|
||||
### CRI 配置
|
||||
|
||||
<!--
|
||||
For more details on setting up CRI runtimes, see [CRI installation](/docs/setup/production-environment/container-runtimes/).
|
||||
-->
|
||||
关于如何安装 CRI 运行时,请查阅 [CRI 安装](/docs/setup/production-environment/container-runtimes/)。
|
||||
### CRI 配置 {#cri-configuration}
|
||||
|
||||
关于如何安装 CRI 运行时,请查阅
|
||||
[CRI 安装](/zh/docs/setup/production-environment/container-runtimes/)。
|
||||
|
||||
#### dockershim
|
||||
|
||||
<!--
|
||||
Kubernetes built-in dockershim CRI does not support runtime handlers.
|
||||
-->
|
||||
Kubernetes 内置 dockershim CRI 不支持配置运行时 handler。
|
||||
Kubernetes 内置的 dockershim CRI 不支持配置运行时 handler。
|
||||
|
||||
#### [containerd](https://containerd.io/)
|
||||
|
||||
@@ -223,8 +224,9 @@ handlers are configured under the [crio.runtime
|
||||
table](https://github.com/kubernetes-sigs/cri-o/blob/master/docs/crio.conf.5.md#crioruntime-table):
|
||||
-->
|
||||
通过 cri-o 的 `/etc/crio/crio.conf` 配置文件来配置运行时 handler。
|
||||
handler 需要配置在 [crio.runtime 表](https://github.com/kubernetes-sigs/cri-o/blob/master/docs/crio.conf.5.md#crioruntime-table)
|
||||
下方:
|
||||
handler 需要配置在
|
||||
[crio.runtime 表](https://github.com/kubernetes-sigs/cri-o/blob/master/docs/crio.conf.5.md#crioruntime-table)
|
||||
下面:
|
||||
|
||||
```
|
||||
[crio.runtime.runtimes.${HANDLER_NAME}]
|
||||
@@ -232,16 +234,14 @@ handler 需要配置在 [crio.runtime 表](https://github.com/kubernetes-sigs/cr
|
||||
```
|
||||
|
||||
<!--
|
||||
See cri-o's config documentation for more details:
|
||||
https://github.com/kubernetes-sigs/cri-o/blob/master/cmd/crio/config.go
|
||||
See CRI-O's [config documentation](https://raw.githubusercontent.com/cri-o/cri-o/9f11d1d/docs/crio.conf.5.md) for more details.
|
||||
-->
|
||||
更详细信息,请查阅 containerd 配置文档:
|
||||
https://github.com/kubernetes-sigs/cri-o/blob/master/cmd/crio/config.go
|
||||
更详细信息,请查阅 CRI-O [配置文档](https://raw.githubusercontent.com/cri-o/cri-o/9f11d1d/docs/crio.conf.5.md)。
|
||||
|
||||
<!--
|
||||
## Scheduling
|
||||
-->
|
||||
## 调度
|
||||
## 调度 {#scheduling}
|
||||
|
||||
{{< feature-state for_k8s_version="v1.16" state="beta" >}}
|
||||
|
||||
@@ -253,7 +253,9 @@ the [RuntimeClass admission controller][] enabled (the default, as of 1.16).
|
||||
-->
|
||||
在 Kubernetes v1.16 版本里,RuntimeClass 特性引入了 `scheduling` 字段来支持异构集群。
|
||||
通过该字段,可以确保 pod 被调度到支持指定运行时的节点上。
|
||||
该调度支持,需要确保 [RuntimeClass admission controller][] 处于开启状态(1.16 版本默认开启)。
|
||||
该调度支持,需要确保
|
||||
[RuntimeClass 准入控制器](/zh/docs/reference/access-authn-authz/admission-controllers/#runtimeclass)
|
||||
处于开启状态(1.16 版本默认开启)。
|
||||
|
||||
<!--
|
||||
To ensure pods land on nodes supporting a specific RuntimeClass, that set of nodes should have a
|
||||
@@ -280,14 +282,12 @@ To learn more about configuring the node selector and tolerations, see [Assignin
|
||||
Nodes](/docs/concepts/configuration/assign-pod-node/).
|
||||
-->
|
||||
更多有关 node selector 和 tolerations 的配置信息,请查阅
|
||||
[Assigning Pods to Nodes](/docs/concepts/configuration/assign-pod-node/)。
|
||||
|
||||
[RuntimeClass admission controller]: /docs/reference/access-authn-authz/admission-controllers/
|
||||
[将 Pod 分派到节点](/zh/docs/concepts/scheduling-eviction/assign-pod-node/)。
|
||||
|
||||
<!--
|
||||
### Pod Overhead
|
||||
-->
|
||||
### Pod 开销
|
||||
### Pod 开销 {#pod-overhead}
|
||||
|
||||
{{< feature-state for_k8s_version="v1.18" state="beta" >}}
|
||||
|
||||
@@ -298,19 +298,20 @@ To use Pod overhead, you must have the PodOverhead [feature gate](/docs/referenc
|
||||
enabled (it is on by default).
|
||||
-->
|
||||
你可以指定与运行 Pod 相关的 _开销_ 资源。声明开销即允许集群(包括调度器)在决策 Pod 和资源时将其考虑在内。
|
||||
若要使用 Pod 开销特性,你必须确保 PodOverhead [特性开关](/docs/reference/command-line-tools-reference/feature-gates/) 处于开启状态(默认为启用状态)。
|
||||
若要使用 Pod 开销特性,你必须确保 PodOverhead
|
||||
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
|
||||
处于启用状态(默认为启用状态)。
|
||||
|
||||
<!--
|
||||
Pod overhead is defined in RuntimeClass through the `Overhead` fields. Through the use of these fields,
|
||||
you can specify the overhead of running pods utilizing this RuntimeClass and ensure these overheads
|
||||
are accounted for in Kubernetes.
|
||||
-->
|
||||
Pod 开销通过 RuntimeClass 的 `overhead` 字段定义。通过使用这些字段,你可以指定使用该 RuntimeClass 运行 Pod 时的开销并确保 Kubernetes 将这些开销计算在内。
|
||||
|
||||
Pod 开销通过 RuntimeClass 的 `overhead` 字段定义。
|
||||
通过使用这些字段,你可以指定使用该 RuntimeClass 运行 Pod 时的开销并确保 Kubernetes 将这些开销计算在内。
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
|
||||
<!--
|
||||
- [RuntimeClass Design](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/runtime-class.md)
|
||||
- [RuntimeClass Scheduling Design](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/runtime-class-scheduling.md)
|
||||
@@ -319,7 +320,7 @@ Pod 开销通过 RuntimeClass 的 `overhead` 字段定义。通过使用这些
|
||||
-->
|
||||
- [RuntimeClass 设计](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/runtime-class.md)
|
||||
- [RuntimeClass 调度设计](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/runtime-class-scheduling.md)
|
||||
- 阅读关于 [Pod 开销](/docs/concepts/configuration/pod-overhead/) 的概念
|
||||
- 阅读关于 [Pod 开销](/zh/docs/concepts/configuration/pod-overhead/) 的概念
|
||||
- [PodOverhead 特性设计](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/20190226-pod-overhead.md)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user