Skip to content

Commit 175a24a

Browse files
authored
Merge pull request #4164 from byako/kep3063-kubelet-v1alpha3
KEP-3063: dynamic resource allocation: update kubelet plugin RPC versions supported.
2 parents 384510b + d1e3e10 commit 175a24a

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

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

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

2047+
Key difference between interface versions:
2048+
2049+
- [v1alpha2](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.proto)
2050+
interface provides resource claim information to a kubelet plugin one at a
2051+
time. **Note: v1alpha2 will be deprecared, switch to v1alpha3**
2052+
- [v1alpha3](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha3/api.proto)
2053+
interface provides information about all resource claims of a pod that belong
2054+
to a particular driver in a single call. This way the kubelet plugin of this driver can consider all
2055+
resources that need to be prepared or unprepared for the pod simultaneously.
2056+
2057+
20472058
##### `NodePrepareResource`
20482059

20492060
This RPC is called by the kubelet when a Pod that wants to use the specified
20502061
resource is scheduled on a node. The Plugin SHALL assume that this RPC will be
20512062
executed on the node where the resource will be used.
2052-
ResourceClaim.meta.Namespace, ResourceClaim.meta.UID, ResourceClaim.Name,
2053-
ResourceClaim.meta.Namespace and one of the ResourceHandles from the
2054-
ResourceClaimStatus.AllocationResult with a matching DriverName should be
2055-
passed to the Plugin as parameters to identify the claim and perform resource
2056-
preparation.
2063+
2064+
ResourceClaim.meta.Namespace, ResourceClaim.meta.UID, ResourceClaim.Name and
2065+
one of the ResourceHandles from the ResourceClaimStatus.AllocationResult with
2066+
a matching DriverName should be passed to the Plugin as parameters to identify
2067+
the claim and perform resource preparation.
20572068

20582069
ResourceClaim parameters (namespace, UUID, name) are useful for debugging.
20592070
They enable the Plugin to retrieve the full ResourceClaim object, should it
@@ -2080,7 +2091,17 @@ MAY choose to call `NodePrepareResource` again, or choose to call
20802091

20812092
On a successful call this RPC should return set of fully qualified
20822093
CDI device names, which kubelet MUST pass to the runtime through the CRI
2083-
protocol.
2094+
protocol. For version v1alpha3, the RPC should return multiple sets of
2095+
fully qualified CDI device names, one per claim that was sent in the input parameters.
2096+
2097+
2098+
###### v1alpha2
2099+
2100+
> [!WARNING]
2101+
> v1alpha2 will be deprecated, switch to v1alpha3.
2102+
2103+
<details>
2104+
<summary>v1alpha2</summary>
20842105

20852106
```protobuf
20862107
message NodePrepareResourceRequest {
@@ -2106,6 +2127,52 @@ message NodePrepareResourceResponse {
21062127
}
21072128
```
21082129

2130+
</details>
2131+
2132+
###### v1alpha3
2133+
2134+
```protobuf
2135+
message NodePrepareResourcesRequest {
2136+
// The list of ResourceClaims that are to be prepared.
2137+
repeated Claim claims = 1;
2138+
}
2139+
2140+
message Claim {
2141+
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
2142+
// This field is REQUIRED.
2143+
string namespace = 1;
2144+
// The UID of the Resource claim (ResourceClaim.meta.UUID).
2145+
// This field is REQUIRED.
2146+
string uid = 2;
2147+
// The name of the Resource claim (ResourceClaim.meta.Name)
2148+
// This field is REQUIRED.
2149+
string name = 3;
2150+
// Resource handle (AllocationResult.ResourceHandles[*].Data)
2151+
// This field is REQUIRED.
2152+
string resource_handle = 4;
2153+
}
2154+
2155+
message NodePrepareResourcesResponse {
2156+
// The ResourceClaims for which preparation was done
2157+
// or attempted, with claim_uid as key.
2158+
//
2159+
// It is an error if some claim listed in NodePrepareResourcesRequest
2160+
// does not get prepared. NodePrepareResources
2161+
// will be called again for those that are missing.
2162+
map<string, NodePrepareResourceResponse> claims = 1;
2163+
}
2164+
2165+
message NodePrepareResourceResponse {
2166+
// These are the additional devices that kubelet must
2167+
// make available via the container runtime. A resource
2168+
// may have zero or more devices.
2169+
repeated string cdi_devices = 1 [(gogoproto.customname) = "CDIDevices"];
2170+
// If non-empty, preparing the ResourceClaim failed.
2171+
// cdi_devices is ignored in that case.
2172+
string error = 2;
2173+
}
2174+
```
2175+
21092176
CRI protocol MUST be extended for this purpose:
21102177

21112178
* CDIDevice structure should be added to the CRI specification
@@ -2162,13 +2229,21 @@ kubelet at least once for each successful `NodePrepareResource`. The
21622229
Plugin SHALL assume that this RPC will be executed on the node where
21632230
the resource is being used.
21642231

2165-
This RPC is called by kubelet when the Pod using the resource is being
2166-
deleted.
2232+
This RPC is called by the kubelet when the last Pod using the resource is being
2233+
deleted or has reached a final state ("Phase" is "done").
21672234

21682235
This operation MUST be idempotent. If this RPC failed, or kubelet does
21692236
not know if it failed or not, it can choose to call
21702237
`NodeUnprepareResource` again.
21712238

2239+
###### v1alpha2
2240+
2241+
> [!WARNING]
2242+
> v1alpha2 will be deprecated, switch to v1alpha3.
2243+
2244+
<details>
2245+
<summary>v1alpha2</summary>
2246+
21722247
```protobuf
21732248
message NodeUnprepareResourceRequest {
21742249
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
@@ -2190,6 +2265,44 @@ message NodeUnprepareResourceResponse {
21902265
}
21912266
```
21922267

2268+
</details>
2269+
2270+
###### v1alpha3
2271+
2272+
```protobuf
2273+
message NodeUnprepareResourcesRequest {
2274+
// The list of ResourceClaims that are to be unprepared.
2275+
repeated Claim claims = 1;
2276+
}
2277+
2278+
message NodeUnprepareResourcesResponse {
2279+
// The ResourceClaims for which preparation was reverted.
2280+
// The same rules as for NodePrepareResourcesResponse.claims
2281+
// apply.
2282+
map<string, NodeUnprepareResourceResponse> claims = 1;
2283+
}
2284+
2285+
message NodeUnprepareResourceResponse {
2286+
// If non-empty, unpreparing the ResourceClaim failed.
2287+
string error = 1;
2288+
}
2289+
2290+
message Claim {
2291+
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
2292+
// This field is REQUIRED.
2293+
string namespace = 1;
2294+
// The UID of the Resource claim (ResourceClaim.meta.UUID).
2295+
// This field is REQUIRED.
2296+
string uid = 2;
2297+
// The name of the Resource claim (ResourceClaim.meta.Name)
2298+
// This field is REQUIRED.
2299+
string name = 3;
2300+
// Resource handle (AllocationResult.ResourceHandles[*].Data)
2301+
// This field is REQUIRED.
2302+
string resource_handle = 4;
2303+
}
2304+
```
2305+
21932306
###### NodeUnprepareResource Errors
21942307

21952308
If the plugin is unable to complete the NodeUprepareResource call

0 commit comments

Comments
 (0)