1
1
---
2
- reviewers :
3
2
title : 设备插件
4
- description : 使用 Kubernetes 设备插件框架来实现适用于 GPU, NIC, FPGA, InfiniBand 以及需要特定于供应商设置的类似资源的插件 。
3
+ description : 使用 Kubernetes 设备插件框架来实现适用于 GPU、 NIC、 FPGA、 InfiniBand 以及类似的需要特定于供应商设置的资源的插件 。
5
4
content_template : templates/concept
6
5
weight : 20
7
6
---
@@ -22,7 +21,7 @@ and setup.
22
21
-->
23
22
Kubernetes 提供了一个[ 设备插件框架] ( https://github.com/kubernetes/community/blob/master/contributors/design-proposals/resource-management/device-plugin.md ) ,您可以用来将系统硬件资源发布到 {{< glossary_tooltip term_id="kubelet" >}}。
24
23
25
- 供应商可以实现您手动部署或作为 {{< glossary_tooltip term_id="daemonset" >}} 部署的设备插件,而不必为 Kubernetes 本身定制代码 。目标设备包括 GPU、高性能NIC 、FPGA、InfiniBand 适配器以及其他类似的计算资源,可能需要特定于供应商的初始化和设置 。
24
+ 供应商可以实现设备插件,由您手动部署或作为 {{< glossary_tooltip term_id="daemonset" >}} 来部署,而不必定制 Kubernetes 本身的代码 。目标设备包括 GPU、高性能 NIC 、FPGA、InfiniBand 适配器以及其他类似的、可能需要特定于供应商的初始化和设置的计算资源 。
26
25
27
26
{{% /capture %}}
28
27
@@ -32,12 +31,6 @@ Kubernetes 提供了一个[设备插件框架](https://github.com/kubernetes/com
32
31
33
32
<!--
34
33
The kubelet exports a `Registration` gRPC service:
35
-
36
- ```gRPC
37
- service Registration {
38
- rpc Register(RegisterRequest) returns (Empty) {}
39
- }
40
- ```
41
34
-->
42
35
kubelet 输出了一个 ` Registration ` 的 gRPC 服务:
43
36
@@ -83,37 +76,18 @@ specification as they request other types of resources, with the following limit
83
76
* Extended resources are only supported as integer resources and cannot be overcommitted.
84
77
* Devices cannot be shared among Containers.
85
78
-->
86
- 然后用户需要去请求其他类型的资源的时候,就可以请求[ 容器] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#container-v1-core)规范中的设备,但是有以下的限制:
87
- * 扩展资源支持整数资源,并且不能被过量使用
79
+ 然后用户需要去请求其他类型的资源的时候,就可以在[ Container] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#container-v1-core)规范请求这类设备,但是有以下的限制:
80
+
81
+ * 扩展资源仅可作为整数资源使用,并且不能被过量使用
88
82
* 设备不能在容器之间共享
89
83
90
84
<!--
91
85
Suppose a Kubernetes cluster is running a device plugin that advertises resource `hardware-vendor.example/foo`
92
86
on certain nodes. Here is an example of a pod requesting this resource to run a demo workload:
93
-
94
- ```yaml
95
- ---
96
- apiVersion: v1
97
- kind: Pod
98
- metadata:
99
- name: demo-pod
100
- spec:
101
- containers:
102
- - name: demo-container-1
103
- image: k8s.gcr.io/pause:2.0
104
- resources:
105
- limits:
106
- hardware-vendor.example/foo: 2
107
- #
108
- # This Pod needs 2 of the hardware-vendor.example/foo devices
109
- # and can only schedule onto a Node that's able to satisfy
110
- # that need.
111
- #
112
- # If the Node has more than 2 of those devices available, the
113
- # remainder would be available for other Pods to use.
114
- ```
115
87
-->
116
- 假设 Kubernetes 集群正在运行一个设备插件,该插件在一些节点上公布的资源为 ` hardware-vendor.example/foo ` ,下面就是一个 pod 运行请求此资源的示例:
88
+
89
+ 假设 Kubernetes 集群正在运行一个设备插件,该插件在一些节点上公布的资源为 ` hardware-vendor.example/foo ` 。
90
+ 下面就是一个 Pod 示例,请求此资源以运行某演示负载:
117
91
118
92
``` yaml
119
93
---
@@ -145,6 +119,14 @@ The general workflow of a device plugin includes the following steps:
145
119
146
120
* The plugin starts a gRPC service, with a Unix socket under host path
147
121
`/var/lib/kubelet/device-plugins/`, that implements the following interfaces:
122
+ -->
123
+
124
+ ## 设备插件的实现
125
+
126
+ 设备插件的常规工作流程包括以下几个步骤:
127
+
128
+ * 初始化。在这个阶段,设备插件将执行供应商特定的初始化和设置,以确保设备处于就绪状态。
129
+ * 插件使用主机路径 ` /var/lib/kubelet/device-plugins/ ` 下的 Unix socket 启动一个 gRPC 服务,该服务实现以下接口:
148
130
149
131
``` gRPC
150
132
service DevicePlugin {
@@ -160,6 +142,7 @@ The general workflow of a device plugin includes the following steps:
160
142
}
161
143
```
162
144
145
+ <!--
163
146
* The plugin registers itself with the kubelet through the Unix socket at host
164
147
path `/var/lib/kubelet/device-plugins/kubelet.sock`.
165
148
@@ -171,29 +154,9 @@ If the operations succeed, the device plugin returns an `AllocateResponse` that
171
154
runtime configurations for accessing the allocated devices. The kubelet passes this information
172
155
to the container runtime.
173
156
-->
174
- ## 设备插件的实现
175
-
176
- 设备插件的常规工作流程包括以下几个步骤:
177
-
178
- * 初始化。在这个阶段,设备插件将执行供应商特定的初始化和设置,以确保设备处于就绪状态。
179
- * 插件使用主机路径 ` /var/lib/kubelet/device-plugins/ ` 下的 Unix socket 启动一个 gRPC 服务,该服务实现以下接口:
180
-
181
- ``` gRPC
182
- service DevicePlugin {
183
- // ListAndWatch returns a stream of List of Devices
184
- // Whenever a Device state change or a Device disappears, ListAndWatch
185
- // returns the new list
186
- rpc ListAndWatch(Empty) returns (stream ListAndWatchResponse) {}
187
-
188
- // Allocate is called during container creation so that the Device
189
- // Plugin can run device specific operations and instruct Kubelet
190
- // of the steps to make the Device available in the container
191
- rpc Allocate(AllocateRequest) returns (AllocateResponse) {}
192
- }
193
- ```
194
157
195
- * 插件通过 Unix socket 在主机路径 ` / var / lib / kubelet / device-plugins / kubelet.sock ` 处向 kubelet 注册自身。
196
- * 成功注册自身后,设备插件将以服务模式运行,在此期间,它将持续监控设备运行状况,并在设备状态发生任何变化时向 kubelet 报告。它还负责 ` 分配 ` gRPC 请求。在` 分配 ` 期间,设备插件可能还会做一些设备特定的准备;例如 GPU 清理或 QRNG 初始化。如果操作成功,则设备插件将返回 ` AllocateResponse ` ,其中包含用于访问被分配的设备容器运行时的配置。kubelet将此信息传递到容器运行时 。
158
+ * 插件通过 Unix socket 在主机路径 ` /var/ lib/ kubelet/ device-plugins/ kubelet.sock ` 处向 kubelet 注册自身。
159
+ * 成功注册自身后,设备插件将以服务模式运行,在此期间,它将持续监控设备运行状况,并在设备状态发生任何变化时向 kubelet 报告。它还负责响应 ` Allocate ` gRPC 请求。在` Allocate ` 期间,设备插件可能还会做一些设备特定的准备;例如 GPU 清理或 QRNG 初始化。如果操作成功,则设备插件将返回 ` AllocateResponse ` ,其中包含用于访问被分配的设备容器运行时的配置。kubelet 将此信息传递到容器运行时 。
197
160
198
161
<!--
199
162
### Handling kubelet restarts
@@ -205,7 +168,7 @@ of its Unix socket and re-register itself upon such an event.
205
168
-->
206
169
### 处理 kubelet 重启
207
170
208
- 一个设备是要能够监测到 kubelet 重启,并且向新的 kubelet 实例来重新注册自己。在当前实现中,当 kubelet 重启的时候,新的 kubelet 实例会删除 ` /var/lib/kubelet/device-plugins ` 下所有已经存在的 Unix sockets,一个设备插件需要能够监控到它的 Unix socket 被删除,并且当发生此类事件时重新注册自己。
171
+ 设备插件应能监测到 kubelet 重启,并且向新的 kubelet 实例来重新注册自己。在当前实现中,当 kubelet 重启的时候,新的 kubelet 实例会删除 ` /var/lib/kubelet/device-plugins ` 下所有已经存在的 Unix sockets。设备插件需要能够监控到它的 Unix socket 被删除,并且当发生此类事件时重新注册自己。
209
172
210
173
<!--
211
174
## Device plugin deployment
@@ -225,7 +188,7 @@ Pod onto Nodes, to restart the daemon Pod after failure, and to help automate up
225
188
-->
226
189
## 设备插件部署
227
190
228
- 你可以降你的设备插件作为你的节点系统的软件包部署为 DaemonSet,或者手动去部署 。
191
+ 你可以将你的设备插件作为节点操作系统的软件包来部署、作为 DaemonSet 来部署或者手动部署 。
229
192
230
193
规范目录 ` /var/lib/kubelet/device-plugins ` 是需要特权访问的,所以设备插件必须要在被授权的安全的上下文中运行。如果你将设备插件部署为 DaemonSet,` /var/lib/kubelet/device-plugins ` 目录必须要在插件的 [ PodSpec] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core) 中声明作为 {{< glossary_tooltip term_id="volume" >}} 被 mount 到插件中。
231
194
@@ -247,7 +210,7 @@ ensure the continuous functioning of the device allocations during the upgrade.
247
210
-->
248
211
## API 兼容性
249
212
250
- Kubernetes 设备插件支持还处于 beta 版本。所以在稳定版本出来之前 API 会以不兼容的方式进行更改, 作为一个项目,Kubernetes 建议设备插件开发者:
213
+ Kubernetes 设备插件支持还处于 beta 版本。所以在稳定版本出来之前 API 会以不兼容的方式进行更改。 作为一个项目,Kubernetes 建议设备插件开发者:
251
214
252
215
* 注意未来版本的更改
253
216
* 支持多个版本的设备插件 API,以实现向后/向前兼容性。
@@ -275,6 +238,8 @@ identifying containers using `pod`, `namespace`, and `container` prometheus labe
275
238
<!--
276
239
The kubelet provides a gRPC service to enable discovery of in-use devices, and to provide metadata
277
240
for these devices:
241
+ -->
242
+ kubelet 提供了 gRPC 服务来使得正在使用中的设备被发现,并且还未这些设备提供了元数据:
278
243
279
244
``` gRPC
280
245
// PodResourcesLister is a service provided by the kubelet that provides information about the
@@ -284,6 +249,7 @@ service PodResourcesLister {
284
249
}
285
250
```
286
251
252
+ <!--
287
253
The gRPC service is served over a unix socket at `/var/lib/kubelet/pod-resources/kubelet.sock`.
288
254
Monitoring agents for device plugin resources can be deployed as a daemon, or as a DaemonSet.
289
255
The canonical directory `/var/lib/kubelet/pod-resources` requires privileged access, so monitoring
@@ -294,19 +260,9 @@ DaemonSet, `/var/lib/kubelet/pod-resources` must be mounted as a
294
260
295
261
Support for the "PodResources service" requires `KubeletPodResources` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) to be enabled. It is enabled by default starting with Kubernetes 1.15.
296
262
-->
297
- kubelet 提供了gRPC服务来使得正在使用中的设备被发现,并且还未这些设备提供了元数据:
298
-
299
- ``` gRPC
300
- // PodResourcesLister is a service provided by the kubelet that provides information about the
301
- // node resources consumed by pods and containers on the node
302
- service PodResourcesLister {
303
- rpc List(ListPodResourcesRequest) returns (ListPodResourcesResponse) {}
304
- }
305
- ```
306
-
307
- gRPC服务通过 ` /var/lib/kubelet/pod-resources/kubelet.sock ` 的 unix socket 来提供服务。设备插件资源的监控代理程序可以部署为守护进程或者 DaemonSet。规范的路径 ` /var/lib/kubelet/pod-resources ` 需要特权来进入,所以监控代理程序必须要在获得授权的安全的上下文中运行。如果设备监控代理以 DaemonSet 形式运行,必须要在插件的 [ PodSpec] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core) 中声明将 ` /var/lib/kubelet/pod-resources ` 目录以 {{< glossary_tooltip term_id="volume" >}} 形式被 mount 到容器中。
263
+ gRPC 服务通过 ` /var/lib/kubelet/pod-resources/kubelet.sock ` 的 UNIX 套接字来提供服务。设备插件资源的监控代理程序可以部署为守护进程或者 DaemonSet。规范的路径 ` /var/lib/kubelet/pod-resources ` 需要特权来进入,所以监控代理程序必须要在获得授权的安全的上下文中运行。如果设备监控代理以 DaemonSet 形式运行,必须要在插件的 [ PodSpec] (/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core) 中声明将 ` /var/lib/kubelet/pod-resources ` 目录以 {{< glossary_tooltip term_id="volume" >}} 形式被 mount 到容器中。
308
264
309
- 对“PodResources 服务”的支持要求启用“ KubeletPodResources” [ feature gate ] ( /docs/reference/command-line-tools-reference/feature-gates/ ) 。从 Kubernetes 1.15 开始默认启用。
265
+ 对“PodResources 服务”的支持要求启用 ` KubeletPodResources ` [ 特性门控 ] ( /docs/reference/command-line-tools-reference/feature-gates/ ) 。从 Kubernetes 1.15 开始默认启用。
310
266
311
267
<!--
312
268
## Device Plugin integration with the Topology Manager
@@ -392,9 +348,9 @@ Here are some examples of device plugin implementations:
392
348
* Read about using [hardware acceleration for TLS ingress](https://kubernetes.io/blog/2019/04/24/hardware-accelerated-ssl/tls-termination-in-ingress-controllers-using-kubernetes-device-plugins-and-runtimeclass/) with Kubernetes
393
349
* Learn about the [Topology Manager] (/docs/tasks/adminster-cluster/topology-manager/)
394
350
-->
395
- * 查看 [ scheduling GPU resources ] ( /docs/tasks/manage-gpus/scheduling-gpus/ ) 来学习使用设备插件
396
- * 查看在 node 上如何 [ advertising extended resources ] ( /docs/tasks/administer-cluster/extended-resource-node/ )
397
- * 阅读如何在 Kubernetes 中如何使用 [ hardware acceleration for TLS ingress ] ( https://kubernetes.io/blog/2019/04/24/hardware-accelerated-ssl/tls-termination-in-ingress-controllers-using-kubernetes-device-plugins-and-runtimeclass/ )
351
+ * 查看 [ 调度 GPU 资源 ] ( /docs/tasks/manage-gpus/scheduling-gpus/ ) 来学习使用设备插件
352
+ * 查看在 node 上如何[ 广告扩展资源 ] ( /docs/tasks/administer-cluster/extended-resource-node/ )
353
+ * 阅读如何在 Kubernetes 中如何使用 [ TLS 入口的硬件加速 ] ( https://kubernetes.io/blog/2019/04/24/hardware-accelerated-ssl/tls-termination-in-ingress-controllers-using-kubernetes-device-plugins-and-runtimeclass/ )
398
354
* 学习 [ Topology Manager] (/docs/tasks/adminster-cluster/topology-manager/)
399
355
400
356
{{% /capture %}}
0 commit comments