Skip to content

Commit c688bcd

Browse files
authored
Merge pull request #29751 from swatisehgal/clarify-podsresource-getallocatable
Pod Resource API: graduate getAllocatableResources to Beta
2 parents f235dc6 + c7231c8 commit c688bcd

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

content/en/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ service PodResourcesLister {
197197
}
198198
```
199199

200+
### `List` gRPC endpoint {#grpc-endpoint-list}
201+
200202
The `List` endpoint provides information on resources of running pods, with details such as the
201203
id of exclusively allocated CPUs, device id as it was reported by device plugins and id of
202204
the NUMA node where these devices are allocated. Also, for NUMA-based machines, it contains the information about memory and hugepages reserved for a container.
@@ -246,10 +248,35 @@ message ContainerDevices {
246248
TopologyInfo topology = 3;
247249
}
248250
```
251+
{{< note >}}
252+
cpu_ids in the `ContainerResources` in the `List` endpoint correspond to exclusive CPUs allocated
253+
to a partilar container. If the goal is to evaluate CPUs that belong to the shared pool, the `List`
254+
endpoint needs to be used in conjunction with the `GetAllocatableResources` endpoint as explained
255+
below:
256+
1. Call `GetAllocatableResources` to get a list of all the allocatable CPUs
257+
2. Call `GetCpuIds` on all `ContainerResources` in the system
258+
3. Subtract out all of the CPUs from the `GetCpuIds` calls from the `GetAllocatableResources` call
259+
{{< /note >}}
260+
261+
### `GetAllocatableResources` gRPC endpoint {#grpc-endpoint-getallocatableresources}
262+
263+
{{< feature-state state="beta" for_k8s_version="v1.23" >}}
249264

250265
GetAllocatableResources provides information on resources initially available on the worker node.
251266
It provides more information than kubelet exports to APIServer.
252267

268+
{{< note >}}
269+
`GetAllocatableResources` should only be used to evaluate [allocatable](/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)
270+
resources on a node. If the goal is to evaluate free/unallocated resources it should be used in
271+
conjunction with the List() endpoint. The result obtained by `GetAllocatableResources` would remain
272+
the same unless the underlying resources exposed to kubelet change. This happens rarely but when
273+
it does (for example: hotplug/hotunplug, device health changes), client is expected to call
274+
`GetAlloctableResources` endpoint.
275+
However, calling `GetAllocatableResources` endpoint is not sufficient in case of cpu and/or memory
276+
update and Kubelet needs to be restarted to reflect the correct resource capacity and allocatable.
277+
{{< /note >}}
278+
279+
253280
```gRPC
254281
// AllocatableResourcesResponses contains informations about all the devices known by the kubelet
255282
message AllocatableResourcesResponse {
@@ -259,6 +286,13 @@ message AllocatableResourcesResponse {
259286
}
260287
261288
```
289+
Starting from Kubernetes v1.23, the `GetAllocatableResources` is enabled by default.
290+
You can disable it by turning off the
291+
`KubeletPodResourcesGetAllocatable` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
292+
293+
Preceding Kubernetes v1.23, to enable this feature `kubelet` must be started with the following flag:
294+
295+
`--feature-gates=KubeletPodResourcesGetAllocatable=true`
262296

263297
`ContainerDevices` do expose the topology information declaring to which NUMA cells the device is affine.
264298
The NUMA cells are identified using a opaque integer ID, which value is consistent to what device

0 commit comments

Comments
 (0)