Skip to content

Commit ccacf27

Browse files
committed
KEP-3695: extend pod resource API to for DRA
Signed-off-by: Moshe Levi <[email protected]>
1 parent d798b36 commit ccacf27

File tree

3 files changed

+445
-0
lines changed

3 files changed

+445
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# The KEP must have an approver from the
2+
# "prod-readiness-approvers" group
3+
# of http://git.k8s.io/enhancements/OWNERS_ALIASES
4+
kep-number: 3695
5+
alpha:
6+
approver: "@johnbelamaric"
Lines changed: 383 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,383 @@
1+
# KEP-3695: Extend the PodResources API to include resources allocated by DRA
2+
3+
<!-- toc -->
4+
- [Release Signoff Checklist](#release-signoff-checklist)
5+
- [Summary](#summary)
6+
- [Motivation](#motivation)
7+
- [Goals](#goals)
8+
- [Non-Goals](#non-goals)
9+
- [Proposal](#proposal)
10+
- [Risks and Mitigations](#risks-and-mitigations)
11+
- [Design Details](#design-details)
12+
- [Proposed API](#proposed-api)
13+
- [Unit tests](#unit-tests)
14+
- [Integration tests](#integration-tests)
15+
- [e2e tests](#e2e-tests)
16+
- [Graduation Criteria](#graduation-criteria)
17+
- [Alpha](#alpha)
18+
- [Beta](#beta)
19+
- [GA](#ga)
20+
- [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy)
21+
- [Version Skew Strategy](#version-skew-strategy)
22+
- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire)
23+
- [Feature Enablement and Rollback](#feature-enablement-and-rollback)
24+
- [Rollout, Upgrade and Rollback Planning](#rollout-upgrade-and-rollback-planning)
25+
- [Monitoring Requirements](#monitoring-requirements)
26+
- [Dependencies](#dependencies)
27+
- [Scalability](#scalability)
28+
- [Troubleshooting](#troubleshooting)
29+
- [Implementation History](#implementation-history)
30+
- [Drawbacks](#drawbacks)
31+
- [Alternatives](#alternatives)
32+
<!-- /toc -->
33+
34+
## Release Signoff Checklist
35+
36+
Items marked with (R) are required *prior to targeting to a milestone / release*.
37+
38+
- [x] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
39+
- [ ] (R) KEP approvers have approved the KEP status as `implementable`
40+
- [ ] (R) Design details are appropriately documented
41+
- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors)
42+
- [ ] e2e Tests for all Beta API Operations (endpoints)
43+
- [ ] (R) Ensure GA e2e tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
44+
- [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free
45+
- [ ] (R) Graduation criteria is in place
46+
- [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
47+
- [ ] (R) Production readiness review completed
48+
- [ ] (R) Production readiness review approved
49+
- [ ] "Implementation History" section is up-to-date for milestone
50+
- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
51+
- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
52+
53+
<!--
54+
**Note:** This checklist is iterative and should be reviewed and updated every time this enhancement is being considered for a milestone.
55+
-->
56+
57+
[kubernetes.io]: https://kubernetes.io/
58+
[kubernetes/enhancements]: https://git.k8s.io/enhancements
59+
[kubernetes/kubernetes]: https://git.k8s.io/kubernetes
60+
[kubernetes/website]: https://git.k8s.io/website
61+
62+
## Summary
63+
64+
We propose an enhancement to the PodResources API to include resources allocated by [Dynamic Resource Allocation (DRA)](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/3063-dynamic-resource-allocation). We also propose to extend the API to be more friendly for consumption by CNI meta-plugins.
65+
This KEP extends [2043-pod-resource-concrete-assigments](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2043-pod-resource-concrete-assigments) and [2403-pod-resources-allocatable-resources](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2403-pod-resources-allocatable-resources).
66+
67+
## Motivation
68+
69+
One of the primary motivations for this KEP is to extend the PodResources API to allow node monitoring agents to access information about resources allocated by DRA. The PodResources API is also being used by CNI meta-plugins like [multus](https://github.com/k8snetworkplumbingwg/multus-cni) and [DANM](https://github.com/nokia/danm) to add resources allocated by device plugins as CNI arguments. This extension can be used to allow these CNI plugins to reference resources allocated by DRA as well. Additional extensions to the API will also make it easier for CNI meta-plugins to access resources allocated to a specific pod, rather than having to filter through resources for all pods on the node.
70+
71+
### Goals
72+
73+
- To allow node monitoring agents to know the allocated DRA resources for Pods on a node.
74+
- To allow the DRA feature to work with CNIs that require complex network devices such as RDMA. DRA resource drivers will allocate the resources, and the meta-plugin will read the allocated [CDI Devices](https://github.com/container-orchestrated-devices/container-device-interface) using the PodResources API. The meta-plugin will then inject the device-id of these CDI Devices as CNI arguments and invoke other CNIs (just as it does for devices allocated by the device plugin today).
75+
76+
### Non-Goals
77+
78+
To enhance the GetAllocatableResources() call in the PodResources API to account for resources managed by DRA. With DRA there is no standard way to get the capacity, for example.
79+
80+
## Proposal
81+
82+
### Risks and Mitigations
83+
84+
This API is read-only, which removes a large class of risks. The aspects that we consider below are as follows:
85+
- What are the risks associated with the API service itself?
86+
- What are the risks associated with the data itself?
87+
88+
| Risk | Impact | Mitigation |
89+
| --------------------------------------------------------- | ------------- | ---------- |
90+
| Too many requests risk impacting the kubelet performances | High | Implement rate limiting and or passive caching, follow best practices for gRPC resource management. |
91+
| Improper access to the data | Low | Server is listening on a root owned unix socket. This can be limited with proper pod security policies. |
92+
93+
## Design Details
94+
95+
### Proposed API
96+
97+
98+
Our proposal is to extend the existing PodResources gRPC service of the Kubelet with a repeated DynamicResource field in the ContainerResources message. This new field will contain information about the DRA resource class, the DRA resource claim and a list of CDI Devices allocated by a DRA driver.
99+
Additionally, we propose adding a Get method to the existing gRPC service to allow querying specific pods for their allocated resources.
100+
101+
The extended interface is shown in proto below:
102+
```protobuf
103+
// PodResourcesLister is a service provided by the kubelet that provides information about the
104+
// node resources consumed by pods and containers on the node
105+
service PodResourcesLister {
106+
rpc List(ListPodResourcesRequest) returns (ListPodResourcesResponse) {}
107+
rpc GetAllocatableResources(AllocatableResourcesRequest) returns (AllocatableResourcesResponse) {}
108+
rpc Get(GetPodResourcesRequest) returns (GetPodResourcesResponse) {}
109+
}
110+
111+
message AllocatableResourcesRequest {}
112+
113+
// AllocatableResourcesResponses contains informations about all the devices known by the kubelet
114+
message AllocatableResourcesResponse {
115+
repeated ContainerDevices devices = 1;
116+
repeated int64 cpu_ids = 2;
117+
repeated ContainerMemory memory = 3;
118+
}
119+
120+
// ListPodResourcesRequest is the request made to the PodResourcesLister service
121+
message ListPodResourcesRequest {}
122+
123+
// ListPodResourcesResponse is the response returned by List function
124+
message ListPodResourcesResponse {
125+
repeated PodResources pod_resources = 1;
126+
}
127+
128+
// PodResources contains information about the node resources assigned to a pod
129+
message PodResources {
130+
string name = 1;
131+
string namespace = 2;
132+
repeated ContainerResources containers = 3;
133+
}
134+
135+
// ContainerResources contains information about the resources assigned to a container
136+
message ContainerResources {
137+
string name = 1;
138+
repeated ContainerDevices devices = 2;
139+
repeated int64 cpu_ids = 3;
140+
repeated ContainerMemory memory = 4;
141+
repeated DynamicResource dynamic_resources = 5;
142+
}
143+
144+
// ContainerMemory contains information about memory and hugepages assigned to a container
145+
message ContainerMemory {
146+
string memory_type = 1;
147+
uint64 size = 2;
148+
TopologyInfo topology = 3;
149+
}
150+
151+
// ContainerDevices contains information about the devices assigned to a container by device plugin
152+
message ContainerDevices {
153+
string resource_name = 1;
154+
repeated string device_ids = 2;
155+
TopologyInfo topology = 3;
156+
}
157+
158+
// Topology describes hardware topology of the resource
159+
message TopologyInfo {
160+
repeated NUMANode nodes = 1;
161+
}
162+
163+
// NUMA representation of NUMA node
164+
message NUMANode {
165+
int64 ID = 1;
166+
}
167+
168+
// DynamicResource contains information about the devices assigned to a container by DRA
169+
message DynamicResource {
170+
string class_name = 1;
171+
string claim_name = 2;
172+
repeated CDIDevice cdi_devices = 3;
173+
}
174+
175+
// CDIDevice specifies a CDI device information
176+
message CDIDevice {
177+
// Fully qualified CDI device name
178+
// for example: vendor.com/gpu=gpudevice1
179+
// see more details in the CDI specification:
180+
// https://github.com/container-orchestrated-devices/container-device-interface/blob/main/SPEC.md
181+
string name = 1;
182+
}
183+
184+
// GetPodResourcesRequest contains information about the pod
185+
message GetPodResourcesRequest {
186+
string name = 1;
187+
string namespace = 2;
188+
}
189+
190+
// GetPodResourcesResponse contains information about the pod the devices
191+
message GetPodResourcesResponse {
192+
PodResources pod_resources = 1;
193+
}
194+
```
195+
196+
197+
##### Unit tests
198+
199+
- `k8s.io/kubernetes/pkg/kubelet/apis/podresources`: `01-24-2023` - `61.5%`
200+
201+
##### Integration tests
202+
203+
These cases will be added in the existing integration tests:
204+
- Feature gate enable/disable tests.
205+
- Get API work with DRA and device plugin.
206+
- List API work with DRA and Device plugin.
207+
208+
##### e2e tests
209+
210+
These cases will be added in the existing e2e tests:
211+
- Feature gate enable/disable tests.
212+
- Get API work with DRA and device plugin.
213+
- List API work with DRA and Device plugin.
214+
215+
### Graduation Criteria
216+
217+
#### Alpha
218+
219+
- [ ] Feature implemented behind a feature flag.
220+
- [ ] e2e tests completed and enabled.
221+
222+
#### Beta
223+
224+
- [ ] Gather feedback from consumers of the DRA feature and k8snetworkplumbingwg working group
225+
- [ ] No major bugs reported in the previous cycle.
226+
227+
#### GA
228+
229+
- [ ] Allowing time for feedback (1 year).
230+
- [ ] Risks have been addressed.
231+
232+
### Upgrade / Downgrade Strategy
233+
234+
With gRPC the version is part of the service name.
235+
Old versions and new versions should always be served and listened by the kubelet.
236+
237+
To a cluster admin upgrading to the newest API version, means upgrading Kubernetes to a newer version as well as upgrading the monitoring component.
238+
239+
To a vendor changes in the API should always be backwards compatible.
240+
241+
### Version Skew Strategy
242+
243+
Kubelet will always be backwards compatible, so going forward existing plugins are not expected to break.
244+
245+
246+
## Production Readiness Review Questionnaire
247+
### Feature Enablement and Rollback
248+
249+
###### How can this feature be enabled / disabled in a live cluster?
250+
251+
- [x] Feature gate (also fill in values in `kep.yaml`)
252+
- Feature gate name for retrieving resources allocated by DRA: `DynamicResourceAllocation` and `PodResourcesDynamicResources`.
253+
- Feature gate name for Get method: `PodResourcesGet`. In case `DynamicResourceAllocation` or the `PodResourcesDynamicResources`
254+
are disabled and `PodResourcesGet` is enabled, the Get method will retrieve resources allocated by device plugins, memory and cpus (but omit those allocated by DRA resource drivers).
255+
In case `PodResourcesGet`, `DynamicResourceAllocation` and `PodResourcesDynamicResources` are all enabled, the Get method will also retrieve the resources allocated via DRA.
256+
- Components depending on the feature gate: kubelet, 3rd party consumers.
257+
258+
###### Does enabling the feature change any default behavior?
259+
260+
No.
261+
262+
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
263+
264+
Yes, through feature gates.
265+
266+
###### What happens if we reenable the feature if it was previously rolled back?
267+
268+
The API becomes available again. The API is stateless, so no recovery is needed, clients can just consume the data.
269+
270+
###### Are there any tests for feature enablement/disablement?
271+
272+
e2e test will demonstrate that when the feature gate is disabled, the API returns the appropriate error code.
273+
274+
### Rollout, Upgrade and Rollback Planning
275+
276+
###### How can a rollout or rollback fail? Can it impact already running workloads?
277+
278+
Kubelet may fail to start. The new API may report inconsistent data, or may cause the kubelet to crash.
279+
280+
###### What specific metrics should inform a rollback?
281+
282+
`pod_resources_endpoint_errors_get` - but only with feature gate `PodResourcesGet` enabled. Otherwise the API will always return a known error.
283+
284+
###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
285+
286+
Not Applicable.
287+
288+
###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
289+
290+
No.
291+
292+
### Monitoring Requirements
293+
294+
###### How can an operator determine if the feature is in use by workloads?
295+
296+
Look at the `pod_resources_endpoint_requests_list` and `pod_resources_endpoint_requests_get` metric exposed by the kubelet.
297+
298+
###### How can someone using this feature know that it is working for their instance?
299+
300+
<!--
301+
For instance, if this is a pod-related feature, it should be possible to determine if the feature is functioning properly
302+
for each individual pod.
303+
Pick one more of these and delete the rest.
304+
Please describe all items visible to end users below with sufficient detail so that they can verify correct enablement
305+
and operation of this feature.
306+
Recall that end users cannot usually observe component logs or access metrics.
307+
-->
308+
309+
- [ ] Events
310+
- Event Reason:
311+
- [ ] API .status
312+
- Condition name:
313+
- Other field:
314+
- [X] Other (treat as last resort)
315+
- Details: check the kubelet metric `pod_resources_endpoint_requests_total`, `pod_resources_endpoint_requests_list` and `pod_resources_endpoint_requests_get`.
316+
317+
###### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
318+
319+
N/A.
320+
321+
###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service?
322+
323+
- [X ] Metrics
324+
- Metric name: `pod_resources_endpoint_requests_total`, `pod_resources_endpoint_requests_list` and `pod_resources_endpoint_requests_get`.
325+
- Components exposing the metric: kubelet
326+
327+
###### Are there any missing metrics that would be useful to have to improve observability of this feature?
328+
329+
As part of this feature enhancement, per-API-endpoint resources metrics are being added; to observe this feature the `pod_resources_endpoint_requests_get` and `pod_resources_endpoint_requests_list` metric should be used. We will add `pod_resources_endpoint_errors_get` error counter.
330+
331+
### Dependencies
332+
333+
###### Does this feature depend on any specific services running in the cluster?
334+
335+
No.
336+
337+
### Scalability
338+
339+
###### Will enabling / using this feature result in any new API calls?
340+
341+
No.
342+
343+
###### Will enabling / using this feature result in introducing new API types?
344+
345+
No.
346+
347+
###### Will enabling / using this feature result in any new calls to the cloud provider?
348+
349+
No.
350+
351+
###### Will enabling / using this feature result in increasing size or count of the existing API objects?
352+
353+
No.
354+
355+
###### Will enabling / using this feature result in increasing time taken by any operations covered by existing SLIs/SLOs?
356+
357+
No. Feature is out of existing any paths in kubelet.
358+
359+
###### Will enabling / using this feature result in non-negligible increase of resource usage (CPU, RAM, disk, IO, ...) in any components?
360+
361+
DDOSing the API can lead to resource exhaustion.
362+
363+
### Troubleshooting
364+
365+
###### How does this feature react if the API server and/or etcd is unavailable?
366+
367+
N/A.
368+
369+
###### What are other known failure modes?
370+
371+
The API will always return a well-known error. In normal operation, the API is expected to never return an error and always return a valid response, because it utilizes internal kubelet data which is always available. Bugs may cause the API to return unexpected errors, or to return inconsistent data. Consumers of the API should treat unexpected errors as bugs of this API.
372+
373+
###### What steps should be taken if SLOs are not being met to determine the problem?
374+
375+
N/A.
376+
377+
## Implementation History
378+
379+
- 2023-01-12: KEP created
380+
381+
## Drawbacks
382+
383+
## Alternatives

0 commit comments

Comments
 (0)