@@ -2039,21 +2039,32 @@ new "ResourcePlugin" type will be used in the Type field of the
2039
2039
[ PluginInfo] ( https://pkg.go.dev/k8s.io/kubelet/pkg/apis/pluginregistration/v1#PluginInfo )
2040
2040
response to distinguish the plugin from device and CSI plugins.
2041
2041
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
2044
2044
[ CSI] ( https://github.com/container-storage-interface/spec/blob/master/spec.md ) ,
2045
2045
with “volume” replaced by “resource” and volume specific parts removed.
2046
2046
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
+
2047
2058
##### ` NodePrepareResource `
2048
2059
2049
2060
This RPC is called by the kubelet when a Pod that wants to use the specified
2050
2061
resource is scheduled on a node. The Plugin SHALL assume that this RPC will be
2051
2062
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.
2057
2068
2058
2069
ResourceClaim parameters (namespace, UUID, name) are useful for debugging.
2059
2070
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
2080
2091
2081
2092
On a successful call this RPC should return set of fully qualified
2082
2093
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 >
2084
2105
2085
2106
``` protobuf
2086
2107
message NodePrepareResourceRequest {
@@ -2106,6 +2127,52 @@ message NodePrepareResourceResponse {
2106
2127
}
2107
2128
```
2108
2129
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
+
2109
2176
CRI protocol MUST be extended for this purpose:
2110
2177
2111
2178
* CDIDevice structure should be added to the CRI specification
@@ -2162,13 +2229,21 @@ kubelet at least once for each successful `NodePrepareResource`. The
2162
2229
Plugin SHALL assume that this RPC will be executed on the node where
2163
2230
the resource is being used.
2164
2231
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") .
2167
2234
2168
2235
This operation MUST be idempotent. If this RPC failed, or kubelet does
2169
2236
not know if it failed or not, it can choose to call
2170
2237
` NodeUnprepareResource ` again.
2171
2238
2239
+ ###### v1alpha2
2240
+
2241
+ > [ !WARNING]
2242
+ > v1alpha2 will be deprecated, switch to v1alpha3.
2243
+
2244
+ <details >
2245
+ <summary >v1alpha2</summary >
2246
+
2172
2247
``` protobuf
2173
2248
message NodeUnprepareResourceRequest {
2174
2249
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
@@ -2190,6 +2265,44 @@ message NodeUnprepareResourceResponse {
2190
2265
}
2191
2266
```
2192
2267
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
+
2193
2306
###### NodeUnprepareResource Errors
2194
2307
2195
2308
If the plugin is unable to complete the NodeUprepareResource call
0 commit comments