1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha2 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 "k8s.io/apimachinery/pkg/runtime" 23 "k8s.io/apimachinery/pkg/types" 24 ) 25 26 const ( 27 // Finalizer is the finalizer that gets set for claims 28 // which were allocated through a builtin controller. 29 Finalizer = "dra.k8s.io/delete-protection" 30 ) 31 32 // +genclient 33 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 34 // +k8s:prerelease-lifecycle-gen:introduced=1.26 35 36 // ResourceClaim describes which resources are needed by a resource consumer. 37 // Its status tracks whether the resource has been allocated and what the 38 // resulting attributes are. 39 // 40 // This is an alpha type and requires enabling the DynamicResourceAllocation 41 // feature gate. 42 type ResourceClaim struct { 43 metav1.TypeMeta `json:",inline"` 44 // Standard object metadata 45 // +optional 46 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 47 48 // Spec describes the desired attributes of a resource that then needs 49 // to be allocated. It can only be set once when creating the 50 // ResourceClaim. 51 Spec ResourceClaimSpec `json:"spec" protobuf:"bytes,2,name=spec"` 52 53 // Status describes whether the resource is available and with which 54 // attributes. 55 // +optional 56 Status ResourceClaimStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 57 } 58 59 // ResourceClaimSpec defines how a resource is to be allocated. 60 type ResourceClaimSpec struct { 61 // ResourceClassName references the driver and additional parameters 62 // via the name of a ResourceClass that was created as part of the 63 // driver deployment. 64 ResourceClassName string `json:"resourceClassName" protobuf:"bytes,1,name=resourceClassName"` 65 66 // ParametersRef references a separate object with arbitrary parameters 67 // that will be used by the driver when allocating a resource for the 68 // claim. 69 // 70 // The object must be in the same namespace as the ResourceClaim. 71 // +optional 72 ParametersRef *ResourceClaimParametersReference `json:"parametersRef,omitempty" protobuf:"bytes,2,opt,name=parametersRef"` 73 74 // Allocation can start immediately or when a Pod wants to use the 75 // resource. "WaitForFirstConsumer" is the default. 76 // +optional 77 AllocationMode AllocationMode `json:"allocationMode,omitempty" protobuf:"bytes,3,opt,name=allocationMode"` 78 } 79 80 // AllocationMode describes whether a ResourceClaim gets allocated immediately 81 // when it gets created (AllocationModeImmediate) or whether allocation is 82 // delayed until it is needed for a Pod 83 // (AllocationModeWaitForFirstConsumer). Other modes might get added in the 84 // future. 85 type AllocationMode string 86 87 const ( 88 // When a ResourceClaim has AllocationModeWaitForFirstConsumer, allocation is 89 // delayed until a Pod gets scheduled that needs the ResourceClaim. The 90 // scheduler will consider all resource requirements of that Pod and 91 // trigger allocation for a node that fits the Pod. 92 AllocationModeWaitForFirstConsumer AllocationMode = "WaitForFirstConsumer" 93 94 // When a ResourceClaim has AllocationModeImmediate, allocation starts 95 // as soon as the ResourceClaim gets created. This is done without 96 // considering the needs of Pods that will use the ResourceClaim 97 // because those Pods are not known yet. 98 AllocationModeImmediate AllocationMode = "Immediate" 99 ) 100 101 // ResourceClaimStatus tracks whether the resource has been allocated and what 102 // the resulting attributes are. 103 type ResourceClaimStatus struct { 104 // DriverName is a copy of the driver name from the ResourceClass at 105 // the time when allocation started. 106 // +optional 107 DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"` 108 109 // Allocation is set by the resource driver once a resource or set of 110 // resources has been allocated successfully. If this is not specified, the 111 // resources have not been allocated yet. 112 // +optional 113 Allocation *AllocationResult `json:"allocation,omitempty" protobuf:"bytes,2,opt,name=allocation"` 114 115 // ReservedFor indicates which entities are currently allowed to use 116 // the claim. A Pod which references a ResourceClaim which is not 117 // reserved for that Pod will not be started. 118 // 119 // There can be at most 32 such reservations. This may get increased in 120 // the future, but not reduced. 121 // 122 // +listType=map 123 // +listMapKey=uid 124 // +patchStrategy=merge 125 // +patchMergeKey=uid 126 // +optional 127 ReservedFor []ResourceClaimConsumerReference `json:"reservedFor,omitempty" protobuf:"bytes,3,opt,name=reservedFor" patchStrategy:"merge" patchMergeKey:"uid"` 128 129 // DeallocationRequested indicates that a ResourceClaim is to be 130 // deallocated. 131 // 132 // The driver then must deallocate this claim and reset the field 133 // together with clearing the Allocation field. 134 // 135 // While DeallocationRequested is set, no new consumers may be added to 136 // ReservedFor. 137 // +optional 138 DeallocationRequested bool `json:"deallocationRequested,omitempty" protobuf:"varint,4,opt,name=deallocationRequested"` 139 } 140 141 // ReservedForMaxSize is the maximum number of entries in 142 // claim.status.reservedFor. 143 const ResourceClaimReservedForMaxSize = 32 144 145 // AllocationResult contains attributes of an allocated resource. 146 type AllocationResult struct { 147 // ResourceHandles contain the state associated with an allocation that 148 // should be maintained throughout the lifetime of a claim. Each 149 // ResourceHandle contains data that should be passed to a specific kubelet 150 // plugin once it lands on a node. This data is returned by the driver 151 // after a successful allocation and is opaque to Kubernetes. Driver 152 // documentation may explain to users how to interpret this data if needed. 153 // 154 // Setting this field is optional. It has a maximum size of 32 entries. 155 // If null (or empty), it is assumed this allocation will be processed by a 156 // single kubelet plugin with no ResourceHandle data attached. The name of 157 // the kubelet plugin invoked will match the DriverName set in the 158 // ResourceClaimStatus this AllocationResult is embedded in. 159 // 160 // +listType=atomic 161 // +optional 162 ResourceHandles []ResourceHandle `json:"resourceHandles,omitempty" protobuf:"bytes,1,opt,name=resourceHandles"` 163 164 // This field will get set by the resource driver after it has allocated 165 // the resource to inform the scheduler where it can schedule Pods using 166 // the ResourceClaim. 167 // 168 // Setting this field is optional. If null, the resource is available 169 // everywhere. 170 // +optional 171 AvailableOnNodes *v1.NodeSelector `json:"availableOnNodes,omitempty" protobuf:"bytes,2,opt,name=availableOnNodes"` 172 173 // Shareable determines whether the resource supports more 174 // than one consumer at a time. 175 // +optional 176 Shareable bool `json:"shareable,omitempty" protobuf:"varint,3,opt,name=shareable"` 177 } 178 179 // AllocationResultResourceHandlesMaxSize represents the maximum number of 180 // entries in allocation.resourceHandles. 181 const AllocationResultResourceHandlesMaxSize = 32 182 183 // ResourceHandle holds opaque resource data for processing by a specific kubelet plugin. 184 type ResourceHandle struct { 185 // DriverName specifies the name of the resource driver whose kubelet 186 // plugin should be invoked to process this ResourceHandle's data once it 187 // lands on a node. This may differ from the DriverName set in 188 // ResourceClaimStatus this ResourceHandle is embedded in. 189 DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"` 190 191 // Data contains the opaque data associated with this ResourceHandle. It is 192 // set by the controller component of the resource driver whose name 193 // matches the DriverName set in the ResourceClaimStatus this 194 // ResourceHandle is embedded in. It is set at allocation time and is 195 // intended for processing by the kubelet plugin whose name matches 196 // the DriverName set in this ResourceHandle. 197 // 198 // The maximum size of this field is 16KiB. This may get increased in the 199 // future, but not reduced. 200 // +optional 201 Data string `json:"data,omitempty" protobuf:"bytes,2,opt,name=data"` 202 203 // If StructuredData is set, then it needs to be used instead of Data. 204 // 205 // +optional 206 StructuredData *StructuredResourceHandle `json:"structuredData,omitempty" protobuf:"bytes,5,opt,name=structuredData"` 207 } 208 209 // ResourceHandleDataMaxSize represents the maximum size of resourceHandle.data. 210 const ResourceHandleDataMaxSize = 16 * 1024 211 212 // StructuredResourceHandle is the in-tree representation of the allocation result. 213 type StructuredResourceHandle struct { 214 // VendorClassParameters are the per-claim configuration parameters 215 // from the resource class at the time that the claim was allocated. 216 // 217 // +optional 218 VendorClassParameters runtime.RawExtension `json:"vendorClassParameters,omitempty" protobuf:"bytes,1,opt,name=vendorClassParameters"` 219 220 // VendorClaimParameters are the per-claim configuration parameters 221 // from the resource claim parameters at the time that the claim was 222 // allocated. 223 // 224 // +optional 225 VendorClaimParameters runtime.RawExtension `json:"vendorClaimParameters,omitempty" protobuf:"bytes,2,opt,name=vendorClaimParameters"` 226 227 // NodeName is the name of the node providing the necessary resources 228 // if the resources are local to a node. 229 // 230 // +optional 231 NodeName string `json:"nodeName,omitempty" protobuf:"bytes,4,name=nodeName"` 232 233 // Results lists all allocated driver resources. 234 // 235 // +listType=atomic 236 Results []DriverAllocationResult `json:"results" protobuf:"bytes,5,name=results"` 237 } 238 239 // DriverAllocationResult contains vendor parameters and the allocation result for 240 // one request. 241 type DriverAllocationResult struct { 242 // VendorRequestParameters are the per-request configuration parameters 243 // from the time that the claim was allocated. 244 // 245 // +optional 246 VendorRequestParameters runtime.RawExtension `json:"vendorRequestParameters,omitempty" protobuf:"bytes,1,opt,name=vendorRequestParameters"` 247 248 AllocationResultModel `json:",inline" protobuf:"bytes,2,name=allocationResultModel"` 249 } 250 251 // AllocationResultModel must have one and only one field set. 252 type AllocationResultModel struct { 253 // NamedResources describes the allocation result when using the named resources model. 254 // 255 // +optional 256 NamedResources *NamedResourcesAllocationResult `json:"namedResources,omitempty" protobuf:"bytes,1,opt,name=namedResources"` 257 } 258 259 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 260 // +k8s:prerelease-lifecycle-gen:introduced=1.26 261 262 // ResourceClaimList is a collection of claims. 263 type ResourceClaimList struct { 264 metav1.TypeMeta `json:",inline"` 265 // Standard list metadata 266 // +optional 267 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 268 269 // Items is the list of resource claims. 270 Items []ResourceClaim `json:"items" protobuf:"bytes,2,rep,name=items"` 271 } 272 273 // +genclient 274 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 275 // +k8s:prerelease-lifecycle-gen:introduced=1.26 276 277 // PodSchedulingContext objects hold information that is needed to schedule 278 // a Pod with ResourceClaims that use "WaitForFirstConsumer" allocation 279 // mode. 280 // 281 // This is an alpha type and requires enabling the DynamicResourceAllocation 282 // feature gate. 283 type PodSchedulingContext struct { 284 metav1.TypeMeta `json:",inline"` 285 // Standard object metadata 286 // +optional 287 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 288 289 // Spec describes where resources for the Pod are needed. 290 Spec PodSchedulingContextSpec `json:"spec" protobuf:"bytes,2,name=spec"` 291 292 // Status describes where resources for the Pod can be allocated. 293 // +optional 294 Status PodSchedulingContextStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 295 } 296 297 // PodSchedulingContextSpec describes where resources for the Pod are needed. 298 type PodSchedulingContextSpec struct { 299 // SelectedNode is the node for which allocation of ResourceClaims that 300 // are referenced by the Pod and that use "WaitForFirstConsumer" 301 // allocation is to be attempted. 302 // +optional 303 SelectedNode string `json:"selectedNode,omitempty" protobuf:"bytes,1,opt,name=selectedNode"` 304 305 // PotentialNodes lists nodes where the Pod might be able to run. 306 // 307 // The size of this field is limited to 128. This is large enough for 308 // many clusters. Larger clusters may need more attempts to find a node 309 // that suits all pending resources. This may get increased in the 310 // future, but not reduced. 311 // 312 // +listType=atomic 313 // +optional 314 PotentialNodes []string `json:"potentialNodes,omitempty" protobuf:"bytes,2,opt,name=potentialNodes"` 315 } 316 317 // PodSchedulingContextStatus describes where resources for the Pod can be allocated. 318 type PodSchedulingContextStatus struct { 319 // ResourceClaims describes resource availability for each 320 // pod.spec.resourceClaim entry where the corresponding ResourceClaim 321 // uses "WaitForFirstConsumer" allocation mode. 322 // 323 // +listType=map 324 // +listMapKey=name 325 // +optional 326 ResourceClaims []ResourceClaimSchedulingStatus `json:"resourceClaims,omitempty" protobuf:"bytes,1,opt,name=resourceClaims"` 327 328 // If there ever is a need to support other kinds of resources 329 // than ResourceClaim, then new fields could get added here 330 // for those other resources. 331 } 332 333 // ResourceClaimSchedulingStatus contains information about one particular 334 // ResourceClaim with "WaitForFirstConsumer" allocation mode. 335 type ResourceClaimSchedulingStatus struct { 336 // Name matches the pod.spec.resourceClaims[*].Name field. 337 // +optional 338 Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` 339 340 // UnsuitableNodes lists nodes that the ResourceClaim cannot be 341 // allocated for. 342 // 343 // The size of this field is limited to 128, the same as for 344 // PodSchedulingSpec.PotentialNodes. This may get increased in the 345 // future, but not reduced. 346 // 347 // +listType=atomic 348 // +optional 349 UnsuitableNodes []string `json:"unsuitableNodes,omitempty" protobuf:"bytes,2,opt,name=unsuitableNodes"` 350 } 351 352 // PodSchedulingNodeListMaxSize defines the maximum number of entries in the 353 // node lists that are stored in PodSchedulingContext objects. This limit is part 354 // of the API. 355 const PodSchedulingNodeListMaxSize = 128 356 357 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 358 // +k8s:prerelease-lifecycle-gen:introduced=1.26 359 360 // PodSchedulingContextList is a collection of Pod scheduling objects. 361 type PodSchedulingContextList struct { 362 metav1.TypeMeta `json:",inline"` 363 // Standard list metadata 364 // +optional 365 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 366 367 // Items is the list of PodSchedulingContext objects. 368 Items []PodSchedulingContext `json:"items" protobuf:"bytes,2,rep,name=items"` 369 } 370 371 // +genclient 372 // +genclient:nonNamespaced 373 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 374 // +k8s:prerelease-lifecycle-gen:introduced=1.26 375 376 // ResourceClass is used by administrators to influence how resources 377 // are allocated. 378 // 379 // This is an alpha type and requires enabling the DynamicResourceAllocation 380 // feature gate. 381 type ResourceClass struct { 382 metav1.TypeMeta `json:",inline"` 383 // Standard object metadata 384 // +optional 385 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 386 387 // DriverName defines the name of the dynamic resource driver that is 388 // used for allocation of a ResourceClaim that uses this class. 389 // 390 // Resource drivers have a unique name in forward domain order 391 // (acme.example.com). 392 DriverName string `json:"driverName" protobuf:"bytes,2,name=driverName"` 393 394 // ParametersRef references an arbitrary separate object that may hold 395 // parameters that will be used by the driver when allocating a 396 // resource that uses this class. A dynamic resource driver can 397 // distinguish between parameters stored here and and those stored in 398 // ResourceClaimSpec. 399 // +optional 400 ParametersRef *ResourceClassParametersReference `json:"parametersRef,omitempty" protobuf:"bytes,3,opt,name=parametersRef"` 401 402 // Only nodes matching the selector will be considered by the scheduler 403 // when trying to find a Node that fits a Pod when that Pod uses 404 // a ResourceClaim that has not been allocated yet. 405 // 406 // Setting this field is optional. If null, all nodes are candidates. 407 // +optional 408 SuitableNodes *v1.NodeSelector `json:"suitableNodes,omitempty" protobuf:"bytes,4,opt,name=suitableNodes"` 409 410 // If and only if allocation of claims using this class is handled 411 // via structured parameters, then StructuredParameters must be set to true. 412 // +optional 413 StructuredParameters *bool `json:"structuredParameters,omitempty" protobuf:"bytes,5,opt,name=structuredParameters"` 414 } 415 416 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 417 // +k8s:prerelease-lifecycle-gen:introduced=1.26 418 419 // ResourceClassList is a collection of classes. 420 type ResourceClassList struct { 421 metav1.TypeMeta `json:",inline"` 422 // Standard list metadata 423 // +optional 424 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 425 426 // Items is the list of resource classes. 427 Items []ResourceClass `json:"items" protobuf:"bytes,2,rep,name=items"` 428 } 429 430 // ResourceClassParametersReference contains enough information to let you 431 // locate the parameters for a ResourceClass. 432 type ResourceClassParametersReference struct { 433 // APIGroup is the group for the resource being referenced. It is 434 // empty for the core API. This matches the group in the APIVersion 435 // that is used when creating the resources. 436 // +optional 437 APIGroup string `json:"apiGroup,omitempty" protobuf:"bytes,1,opt,name=apiGroup"` 438 // Kind is the type of resource being referenced. This is the same 439 // value as in the parameter object's metadata. 440 Kind string `json:"kind" protobuf:"bytes,2,name=kind"` 441 // Name is the name of resource being referenced. 442 Name string `json:"name" protobuf:"bytes,3,name=name"` 443 // Namespace that contains the referenced resource. Must be empty 444 // for cluster-scoped resources and non-empty for namespaced 445 // resources. 446 // +optional 447 Namespace string `json:"namespace,omitempty" protobuf:"bytes,4,opt,name=namespace"` 448 } 449 450 // ResourceClaimParametersReference contains enough information to let you 451 // locate the parameters for a ResourceClaim. The object must be in the same 452 // namespace as the ResourceClaim. 453 type ResourceClaimParametersReference struct { 454 // APIGroup is the group for the resource being referenced. It is 455 // empty for the core API. This matches the group in the APIVersion 456 // that is used when creating the resources. 457 // +optional 458 APIGroup string `json:"apiGroup,omitempty" protobuf:"bytes,1,opt,name=apiGroup"` 459 // Kind is the type of resource being referenced. This is the same 460 // value as in the parameter object's metadata, for example "ConfigMap". 461 Kind string `json:"kind" protobuf:"bytes,2,name=kind"` 462 // Name is the name of resource being referenced. 463 Name string `json:"name" protobuf:"bytes,3,name=name"` 464 } 465 466 // ResourceClaimConsumerReference contains enough information to let you 467 // locate the consumer of a ResourceClaim. The user must be a resource in the same 468 // namespace as the ResourceClaim. 469 type ResourceClaimConsumerReference struct { 470 // APIGroup is the group for the resource being referenced. It is 471 // empty for the core API. This matches the group in the APIVersion 472 // that is used when creating the resources. 473 // +optional 474 APIGroup string `json:"apiGroup,omitempty" protobuf:"bytes,1,opt,name=apiGroup"` 475 // Resource is the type of resource being referenced, for example "pods". 476 Resource string `json:"resource" protobuf:"bytes,3,name=resource"` 477 // Name is the name of resource being referenced. 478 Name string `json:"name" protobuf:"bytes,4,name=name"` 479 // UID identifies exactly one incarnation of the resource. 480 UID types.UID `json:"uid" protobuf:"bytes,5,name=uid"` 481 } 482 483 // +genclient 484 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 485 // +k8s:prerelease-lifecycle-gen:introduced=1.26 486 487 // ResourceClaimTemplate is used to produce ResourceClaim objects. 488 type ResourceClaimTemplate struct { 489 metav1.TypeMeta `json:",inline"` 490 // Standard object metadata 491 // +optional 492 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 493 494 // Describes the ResourceClaim that is to be generated. 495 // 496 // This field is immutable. A ResourceClaim will get created by the 497 // control plane for a Pod when needed and then not get updated 498 // anymore. 499 Spec ResourceClaimTemplateSpec `json:"spec" protobuf:"bytes,2,name=spec"` 500 } 501 502 // ResourceClaimTemplateSpec contains the metadata and fields for a ResourceClaim. 503 type ResourceClaimTemplateSpec struct { 504 // ObjectMeta may contain labels and annotations that will be copied into the PVC 505 // when creating it. No other fields are allowed and will be rejected during 506 // validation. 507 // +optional 508 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 509 510 // Spec for the ResourceClaim. The entire content is copied unchanged 511 // into the ResourceClaim that gets created from this template. The 512 // same fields as in a ResourceClaim are also valid here. 513 Spec ResourceClaimSpec `json:"spec" protobuf:"bytes,2,name=spec"` 514 } 515 516 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 517 // +k8s:prerelease-lifecycle-gen:introduced=1.26 518 519 // ResourceClaimTemplateList is a collection of claim templates. 520 type ResourceClaimTemplateList struct { 521 metav1.TypeMeta `json:",inline"` 522 // Standard list metadata 523 // +optional 524 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 525 526 // Items is the list of resource claim templates. 527 Items []ResourceClaimTemplate `json:"items" protobuf:"bytes,2,rep,name=items"` 528 } 529 530 // +genclient 531 // +genclient:nonNamespaced 532 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 533 // +k8s:prerelease-lifecycle-gen:introduced=1.30 534 535 // ResourceSlice provides information about available 536 // resources on individual nodes. 537 type ResourceSlice struct { 538 metav1.TypeMeta `json:",inline"` 539 // Standard object metadata 540 // +optional 541 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 542 543 // NodeName identifies the node which provides the resources 544 // if they are local to a node. 545 // 546 // A field selector can be used to list only ResourceSlice 547 // objects with a certain node name. 548 // 549 // +optional 550 NodeName string `json:"nodeName,omitempty" protobuf:"bytes,2,opt,name=nodeName"` 551 552 // DriverName identifies the DRA driver providing the capacity information. 553 // A field selector can be used to list only ResourceSlice 554 // objects with a certain driver name. 555 DriverName string `json:"driverName" protobuf:"bytes,3,name=driverName"` 556 557 ResourceModel `json:",inline" protobuf:"bytes,4,name=resourceModel"` 558 } 559 560 // ResourceModel must have one and only one field set. 561 type ResourceModel struct { 562 // NamedResources describes available resources using the named resources model. 563 // 564 // +optional 565 NamedResources *NamedResourcesResources `json:"namedResources,omitempty" protobuf:"bytes,1,opt,name=namedResources"` 566 } 567 568 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 569 // +k8s:prerelease-lifecycle-gen:introduced=1.30 570 571 // ResourceSliceList is a collection of ResourceSlices. 572 type ResourceSliceList struct { 573 metav1.TypeMeta `json:",inline"` 574 // Standard list metadata 575 // +optional 576 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 577 578 // Items is the list of node resource capacity objects. 579 Items []ResourceSlice `json:"items" protobuf:"bytes,2,rep,name=items"` 580 } 581 582 // +genclient 583 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 584 // +k8s:prerelease-lifecycle-gen:introduced=1.30 585 586 // ResourceClaimParameters defines resource requests for a ResourceClaim in an 587 // in-tree format understood by Kubernetes. 588 type ResourceClaimParameters struct { 589 metav1.TypeMeta `json:",inline"` 590 // Standard object metadata 591 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 592 593 // If this object was created from some other resource, then this links 594 // back to that resource. This field is used to find the in-tree representation 595 // of the claim parameters when the parameter reference of the claim refers 596 // to some unknown type. 597 // +optional 598 GeneratedFrom *ResourceClaimParametersReference `json:"generatedFrom,omitempty" protobuf:"bytes,2,opt,name=generatedFrom"` 599 600 // Shareable indicates whether the allocated claim is meant to be shareable 601 // by multiple consumers at the same time. 602 // +optional 603 Shareable bool `json:"shareable,omitempty" protobuf:"bytes,3,opt,name=shareable"` 604 605 // DriverRequests describes all resources that are needed for the 606 // allocated claim. A single claim may use resources coming from 607 // different drivers. For each driver, this array has at most one 608 // entry which then may have one or more per-driver requests. 609 // 610 // May be empty, in which case the claim can always be allocated. 611 // 612 // +listType=atomic 613 DriverRequests []DriverRequests `json:"driverRequests,omitempty" protobuf:"bytes,4,opt,name=driverRequests"` 614 } 615 616 // DriverRequests describes all resources that are needed from one particular driver. 617 type DriverRequests struct { 618 // DriverName is the name used by the DRA driver kubelet plugin. 619 DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"` 620 621 // VendorParameters are arbitrary setup parameters for all requests of the 622 // claim. They are ignored while allocating the claim. 623 // 624 // +optional 625 VendorParameters runtime.RawExtension `json:"vendorParameters,omitempty" protobuf:"bytes,2,opt,name=vendorParameters"` 626 627 // Requests describes all resources that are needed from the driver. 628 // +listType=atomic 629 Requests []ResourceRequest `json:"requests,omitempty" protobuf:"bytes,3,opt,name=requests"` 630 } 631 632 // ResourceRequest is a request for resources from one particular driver. 633 type ResourceRequest struct { 634 // VendorParameters are arbitrary setup parameters for the requested 635 // resource. They are ignored while allocating a claim. 636 // 637 // +optional 638 VendorParameters runtime.RawExtension `json:"vendorParameters,omitempty" protobuf:"bytes,1,opt,name=vendorParameters"` 639 640 ResourceRequestModel `json:",inline" protobuf:"bytes,2,name=resourceRequestModel"` 641 } 642 643 // ResourceRequestModel must have one and only one field set. 644 type ResourceRequestModel struct { 645 // NamedResources describes a request for resources with the named resources model. 646 // 647 // +optional 648 NamedResources *NamedResourcesRequest `json:"namedResources,omitempty" protobuf:"bytes,1,opt,name=namedResources"` 649 } 650 651 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 652 // +k8s:prerelease-lifecycle-gen:introduced=1.30 653 654 // ResourceClaimParametersList is a collection of ResourceClaimParameters. 655 type ResourceClaimParametersList struct { 656 metav1.TypeMeta `json:",inline"` 657 // Standard list metadata 658 // +optional 659 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 660 661 // Items is the list of node resource capacity objects. 662 Items []ResourceClaimParameters `json:"items" protobuf:"bytes,2,rep,name=items"` 663 } 664 665 // +genclient 666 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 667 // +k8s:prerelease-lifecycle-gen:introduced=1.30 668 669 // ResourceClassParameters defines resource requests for a ResourceClass in an 670 // in-tree format understood by Kubernetes. 671 type ResourceClassParameters struct { 672 metav1.TypeMeta `json:",inline"` 673 // Standard object metadata 674 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 675 676 // If this object was created from some other resource, then this links 677 // back to that resource. This field is used to find the in-tree representation 678 // of the class parameters when the parameter reference of the class refers 679 // to some unknown type. 680 // +optional 681 GeneratedFrom *ResourceClassParametersReference `json:"generatedFrom,omitempty" protobuf:"bytes,2,opt,name=generatedFrom"` 682 683 // VendorParameters are arbitrary setup parameters for all claims using 684 // this class. They are ignored while allocating the claim. There must 685 // not be more than one entry per driver. 686 // 687 // +listType=atomic 688 // +optional 689 VendorParameters []VendorParameters `json:"vendorParameters,omitempty" protobuf:"bytes,3,opt,name=vendorParameters"` 690 691 // Filters describes additional contraints that must be met when using the class. 692 // 693 // +listType=atomic 694 Filters []ResourceFilter `json:"filters,omitempty" protobuf:"bytes,4,opt,name=filters"` 695 } 696 697 // ResourceFilter is a filter for resources from one particular driver. 698 type ResourceFilter struct { 699 // DriverName is the name used by the DRA driver kubelet plugin. 700 DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"` 701 702 ResourceFilterModel `json:",inline" protobuf:"bytes,2,name=resourceFilterModel"` 703 } 704 705 // ResourceFilterModel must have one and only one field set. 706 type ResourceFilterModel struct { 707 // NamedResources describes a resource filter using the named resources model. 708 // 709 // +optional 710 NamedResources *NamedResourcesFilter `json:"namedResources,omitempty" protobuf:"bytes,1,opt,name=namedResources"` 711 } 712 713 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 714 // +k8s:prerelease-lifecycle-gen:introduced=1.30 715 716 // ResourceClassParametersList is a collection of ResourceClassParameters. 717 type ResourceClassParametersList struct { 718 metav1.TypeMeta `json:",inline"` 719 // Standard list metadata 720 // +optional 721 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 722 723 // Items is the list of node resource capacity objects. 724 Items []ResourceClassParameters `json:"items" protobuf:"bytes,2,rep,name=items"` 725 } 726 727 // VendorParameters are opaque parameters for one particular driver. 728 type VendorParameters struct { 729 // DriverName is the name used by the DRA driver kubelet plugin. 730 DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"` 731 732 // Parameters can be arbitrary setup parameters. They are ignored while 733 // allocating a claim. 734 // 735 // +optional 736 Parameters runtime.RawExtension `json:"parameters,omitempty" protobuf:"bytes,2,opt,name=parameters"` 737 } 738