Skip to content

Commit ffa34bd

Browse files
committed
DRA: update kubelet plugin RPC versions
1 parent 1202981 commit ffa34bd

File tree

1 file changed

+123
-10
lines changed
  • keps/sig-node/3063-dynamic-resource-allocation

1 file changed

+123
-10
lines changed

keps/sig-node/3063-dynamic-resource-allocation/README.md

Lines changed: 123 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,21 +1989,32 @@ new "ResourcePlugin" type will be used in the Type field of the
19891989
[PluginInfo](https://pkg.go.dev/k8s.io/kubelet/pkg/apis/pluginregistration/v1#PluginInfo)
19901990
response to distinguish the plugin from device and CSI plugins.
19911991

1992-
Under the advertised Unix Domain socket the kubelet plugin provides the following
1993-
gRPC interface. It was inspired by
1992+
Under the advertised Unix Domain socket the kubelet plugin provides one of the
1993+
following supported gRPC interface versions. It was inspired by
19941994
[CSI](https://github.com/container-storage-interface/spec/blob/master/spec.md),
19951995
with “volume” replaced by “resource” and volume specific parts removed.
19961996

1997+
Key difference between interface versions:
1998+
1999+
- [v1alpha2](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.proto)
2000+
interface provides resource claim information to kubelet plugin on one at a
2001+
time basis. **NB! v1alpha2 will be deprecared, switch to v1alpha3**
2002+
- [v1alpha3](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha3/api.proto)
2003+
interface provides information about all resource claims of the pod, that belong
2004+
to particular driver, so the kubelet plugin of this driver can consider all
2005+
resources that need to be prepared or unprepared for the pod in one call.
2006+
2007+
19972008
##### `NodePrepareResource`
19982009

19992010
This RPC is called by the kubelet when a Pod that wants to use the specified
20002011
resource is scheduled on a node. The Plugin SHALL assume that this RPC will be
20012012
executed on the node where the resource will be used.
2002-
ResourceClaim.meta.Namespace, ResourceClaim.meta.UID, ResourceClaim.Name,
2003-
ResourceClaim.meta.Namespace and one of the ResourceHandles from the
2004-
ResourceClaimStatus.AllocationResult with a matching DriverName should be
2005-
passed to the Plugin as parameters to identify the claim and perform resource
2006-
preparation.
2013+
2014+
ResourceClaim.meta.Namespace, ResourceClaim.meta.UID, ResourceClaim.Name and
2015+
one of the ResourceHandles from the ResourceClaimStatus.AllocationResult with
2016+
a matching DriverName should be passed to the Plugin as parameters to identify
2017+
the claim and perform resource preparation.
20072018

20082019
ResourceClaim parameters (namespace, UUID, name) are useful for debugging.
20092020
They enable the Plugin to retrieve the full ResourceClaim object, should it
@@ -2030,7 +2041,17 @@ MAY choose to call `NodePrepareResource` again, or choose to call
20302041

20312042
On a successful call this RPC should return set of fully qualified
20322043
CDI device names, which kubelet MUST pass to the runtime through the CRI
2033-
protocol.
2044+
protocol. For version v1alpha3 the RPC shold return the respective set of
2045+
fully qualified CDI device names per every claim that was sent in parameters.
2046+
2047+
2048+
###### v1alpha2
2049+
2050+
> [!WARNING]
2051+
> v1alpha2 will be deprecated, switch to v1alpha3.
2052+
2053+
<details>
2054+
<summary>v1alpha2</summary>
20342055

20352056
```protobuf
20362057
message NodePrepareResourceRequest {
@@ -2056,6 +2077,52 @@ message NodePrepareResourceResponse {
20562077
}
20572078
```
20582079

2080+
</details>
2081+
2082+
###### v1alpha3
2083+
2084+
```protobuf
2085+
message NodePrepareResourcesRequest {
2086+
// The list of ResourceClaims that are to be prepared.
2087+
repeated Claim claims = 1;
2088+
}
2089+
2090+
message Claim {
2091+
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
2092+
// This field is REQUIRED.
2093+
string namespace = 1;
2094+
// The UID of the Resource claim (ResourceClaim.meta.UUID).
2095+
// This field is REQUIRED.
2096+
string uid = 2;
2097+
// The name of the Resource claim (ResourceClaim.meta.Name)
2098+
// This field is REQUIRED.
2099+
string name = 3;
2100+
// Resource handle (AllocationResult.ResourceHandles[*].Data)
2101+
// This field is REQUIRED.
2102+
string resource_handle = 4;
2103+
}
2104+
2105+
message NodePrepareResourcesResponse {
2106+
// The ResourceClaims for which preparation was done
2107+
// or attempted, with claim_uid as key.
2108+
//
2109+
// It is an error if some claim listed in NodePrepareResourcesRequest
2110+
// does not get prepared. NodePrepareResources
2111+
// will be called again for those that are missing.
2112+
map<string, NodePrepareResourceResponse> claims = 1;
2113+
}
2114+
2115+
message NodePrepareResourceResponse {
2116+
// These are the additional devices that kubelet must
2117+
// make available via the container runtime. A resource
2118+
// may have zero or more devices.
2119+
repeated string cdi_devices = 1 [(gogoproto.customname) = "CDIDevices"];
2120+
// If non-empty, preparing the ResourceClaim failed.
2121+
// cdi_devices is ignored in that case.
2122+
string error = 2;
2123+
}
2124+
```
2125+
20592126
CRI protocol MUST be extended for this purpose:
20602127

20612128
* CDIDevice structure should be added to the CRI specification
@@ -2112,13 +2179,21 @@ kubelet at least once for each successful `NodePrepareResource`. The
21122179
Plugin SHALL assume that this RPC will be executed on the node where
21132180
the resource is being used.
21142181

2115-
This RPC is called by kubelet when the Pod using the resource is being
2116-
deleted.
2182+
This RPC is called by kubelet when the last Pod using the resource is being
2183+
deleted or has come to a final state ("Phase" is "done").
21172184

21182185
This operation MUST be idempotent. If this RPC failed, or kubelet does
21192186
not know if it failed or not, it can choose to call
21202187
`NodeUnprepareResource` again.
21212188

2189+
###### v1alpha2
2190+
2191+
> [!WARNING]
2192+
> v1alpha2 will be deprecated, switch to v1alpha3.
2193+
2194+
<details>
2195+
<summary>v1alpha2</summary>
2196+
21222197
```protobuf
21232198
message NodeUnprepareResourceRequest {
21242199
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
@@ -2140,6 +2215,44 @@ message NodeUnprepareResourceResponse {
21402215
}
21412216
```
21422217

2218+
</details>
2219+
2220+
###### v1alpha3
2221+
2222+
```protobuf
2223+
message NodeUnprepareResourcesRequest {
2224+
// The list of ResourceClaims that are to be unprepared.
2225+
repeated Claim claims = 1;
2226+
}
2227+
2228+
message NodeUnprepareResourcesResponse {
2229+
// The ResourceClaims for which preparation was reverted.
2230+
// The same rules as for NodePrepareResourcesResponse.claims
2231+
// apply.
2232+
map<string, NodeUnprepareResourceResponse> claims = 1;
2233+
}
2234+
2235+
message NodeUnprepareResourceResponse {
2236+
// If non-empty, unpreparing the ResourceClaim failed.
2237+
string error = 1;
2238+
}
2239+
2240+
message Claim {
2241+
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
2242+
// This field is REQUIRED.
2243+
string namespace = 1;
2244+
// The UID of the Resource claim (ResourceClaim.meta.UUID).
2245+
// This field is REQUIRED.
2246+
string uid = 2;
2247+
// The name of the Resource claim (ResourceClaim.meta.Name)
2248+
// This field is REQUIRED.
2249+
string name = 3;
2250+
// Resource handle (AllocationResult.ResourceHandles[*].Data)
2251+
// This field is REQUIRED.
2252+
string resource_handle = 4;
2253+
}
2254+
```
2255+
21432256
###### NodeUnprepareResource Errors
21442257

21452258
If the plugin is unable to complete the NodeUprepareResource call

0 commit comments

Comments
 (0)