From fd9b3076bed1b876877230d9440799b7dd1d8e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=9D=B0=E9=B2=81?= Date: Thu, 31 Mar 2022 11:01:52 +0800 Subject: [PATCH] docs: sync Chinese translation docs: fix review fix: review --- .../compute-storage-net/device-plugins.md | 93 ++++++++++++++++--- 1 file changed, 82 insertions(+), 11 deletions(-) diff --git a/content/zh/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins.md b/content/zh/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins.md index 6fdc0a371f..13ea71b7e0 100644 --- a/content/zh/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins.md +++ b/content/zh/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins.md @@ -40,7 +40,7 @@ The kubelet exports a `Registration` gRPC service: ```gRPC service Registration { - rpc Register(RegisterRequest) returns (Empty) {} + rpc Register(RegisterRequest) returns (Empty) {} } ``` @@ -63,7 +63,7 @@ and reports two healthy devices on a node, the node status is updated to advertise that the node has 2 "Foo" devices installed and available. --> 设备插件可以通过此 gRPC 服务在 kubelet 进行注册。在注册期间,设备插件需要发送下面几样内容: - + * 设备插件的 Unix 套接字。 * 设备插件的 API 版本。 * `ResourceName` 是需要公布的。这里 `ResourceName` 需要遵循 @@ -92,12 +92,14 @@ specification as they request other types of resources, with the following limit * 扩展资源仅可作为整数资源使用,并且不能被过量使用 * 设备不能在容器之间共享 +### 示例 {#example-pod} + 假设 Kubernetes 集群正在运行一个设备插件,该插件在一些节点上公布的资源为 `hardware-vendor.example/foo`。 -下面就是一个 Pod 示例,请求此资源以运行某演示负载: +下面就是一个 Pod 示例,请求此资源以运行一个工作负载的示例: ```yaml --- @@ -140,8 +142,12 @@ The general workflow of a device plugin includes the following steps: 一个 gRPC 服务,该服务实现以下接口: ```gRPC service DevicePlugin { + // GetDevicePluginOptions 返回与设备管理器沟通的选项。 + rpc GetDevicePluginOptions(Empty) returns (DevicePluginOptions) {} + // ListAndWatch 返回 Device 列表构成的数据流。 // 当 Device 状态发生变化或者 Device 消失时,ListAndWatch // 会返回新的列表。 @@ -331,10 +340,12 @@ service PodResourcesLister { } ``` +### `List` gRPC 端点 {#grpc-endpoint-list} + 这一 `List` 端点提供运行中 Pods 的资源信息,包括类似独占式分配的 @@ -387,6 +398,51 @@ message ContainerDevices { } ``` + +{{< note >}} +`List` 端点中的 `ContainerResources` 中的 cpu_ids 对应于分配给某个容器的专属 CPU。 +如果要统计共享池中的 CPU,`List` 端点需要与 `GetAllocatableResources` 端点一起使用,如下所述: + +1. 调用 `GetAllocatableResources` 获取所有可用的 CPUs。 +2. 在系统中所有的 `ContainerResources` 上调用 `GetCpuIds`。 +3. 用 `GetAllocatableResources` 获取的 CPU 数减去 `GetCpuIds` 获取的 CPU 数。 +{{< /note >}} + +### `GetAllocatableResources` gRPC 端点 {#grpc-endpoint-getallocatableresources} + +{{< feature-state state="beta" for_k8s_version="v1.23" >}} + + +{{< note >}} +`GetAllocatableResources` 应该仅被用于评估一个节点上的[可分配的](/zh/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable) +资源。如果目标是评估空闲/未分配的资源,此调用应该与 List() 端点一起使用。 +除非暴露给 kubelet 的底层资源发生变化 否则 `GetAllocatableResources` 得到的结果将保持不变。 +这种情况很少发生,但当发生时(例如:热插拔,设备健康状况改变),客户端应该调用 `GetAlloctableResources` 端点。 +然而,调用 `GetAllocatableResources` 端点在 cpu、内存被更新的情况下是不够的, +Kubelet 需要重新启动以获取正确的资源容量和可分配的资源。 +{{< /note >}} + +从 Kubernetes v1.23 开始,`GetAllocatableResources` 被默认启用。 +你可以通过关闭 `KubeletPodResourcesGetAllocatable` +[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/) 来禁用。 + +在 Kubernetes v1.23 之前,要启用这一功能,`kubelet` 必须用以下标志启动: + +`--feature-gates=KubeletPodResourcesGetAllocatable=true` + * 查看[调度 GPU 资源](/zh/docs/tasks/manage-gpus/scheduling-gpus/) 来学习使用设备插件 * 查看在上如何[公布节点上的扩展资源](/zh/docs/tasks/administer-cluster/extended-resource-node/) -* 阅读如何在 Kubernetes 中使用 [TLS Ingress 的硬件加速](https://kubernetes.io/blog/2019/04/24/hardware-accelerated-ssl/tls-termination-in-ingress-controllers-using-kubernetes-device-plugins-and-runtimeclass/) +* 阅读如何在 Kubernetes 中使用 [TLS Ingress 的硬件加速](https://kubernetes.io/blog/2019/04/24/hardware-accelerated-ssl/tls-termination-in-ingress-controllers-using-kubernetes-device-plugins-and-runtimeclass/) * 学习[拓扑管理器](/zh/docs/tasks/administer-cluster/topology-manager/) - -