@@ -1989,21 +1989,32 @@ new "ResourcePlugin" type will be used in the Type field of the
1989
1989
[ PluginInfo] ( https://pkg.go.dev/k8s.io/kubelet/pkg/apis/pluginregistration/v1#PluginInfo )
1990
1990
response to distinguish the plugin from device and CSI plugins.
1991
1991
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
1994
1994
[ CSI] ( https://github.com/container-storage-interface/spec/blob/master/spec.md ) ,
1995
1995
with “volume” replaced by “resource” and volume specific parts removed.
1996
1996
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
+
1997
2008
##### ` NodePrepareResource `
1998
2009
1999
2010
This RPC is called by the kubelet when a Pod that wants to use the specified
2000
2011
resource is scheduled on a node. The Plugin SHALL assume that this RPC will be
2001
2012
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.
2007
2018
2008
2019
ResourceClaim parameters (namespace, UUID, name) are useful for debugging.
2009
2020
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
2030
2041
2031
2042
On a successful call this RPC should return set of fully qualified
2032
2043
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 >
2034
2055
2035
2056
``` protobuf
2036
2057
message NodePrepareResourceRequest {
@@ -2056,6 +2077,52 @@ message NodePrepareResourceResponse {
2056
2077
}
2057
2078
```
2058
2079
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
+
2059
2126
CRI protocol MUST be extended for this purpose:
2060
2127
2061
2128
* CDIDevice structure should be added to the CRI specification
@@ -2112,13 +2179,21 @@ kubelet at least once for each successful `NodePrepareResource`. The
2112
2179
Plugin SHALL assume that this RPC will be executed on the node where
2113
2180
the resource is being used.
2114
2181
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") .
2117
2184
2118
2185
This operation MUST be idempotent. If this RPC failed, or kubelet does
2119
2186
not know if it failed or not, it can choose to call
2120
2187
` NodeUnprepareResource ` again.
2121
2188
2189
+ ###### v1alpha2
2190
+
2191
+ > [ !WARNING]
2192
+ > v1alpha2 will be deprecated, switch to v1alpha3.
2193
+
2194
+ <details >
2195
+ <summary >v1alpha2</summary >
2196
+
2122
2197
``` protobuf
2123
2198
message NodeUnprepareResourceRequest {
2124
2199
// The ResourceClaim namespace (ResourceClaim.meta.Namespace).
@@ -2140,6 +2215,44 @@ message NodeUnprepareResourceResponse {
2140
2215
}
2141
2216
```
2142
2217
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
+
2143
2256
###### NodeUnprepareResource Errors
2144
2257
2145
2258
If the plugin is unable to complete the NodeUprepareResource call
0 commit comments