mirror of
https://github.com/kubernetes/client-go.git
synced 2026-05-14 19:17:56 +00:00
Merge pull request #136725 from pravk03/native-dra-2
Introduce support of DRA for Native Resources Kubernetes-commit: 7a3a6cf4be719a2eaed14e48a701cbdd2f0e8400
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// NodeAllocatableResourceClaimStatusApplyConfiguration represents a declarative configuration of the NodeAllocatableResourceClaimStatus type for use
|
||||
// with apply.
|
||||
//
|
||||
// NodeAllocatableResourceClaimStatus describes the status of node allocatable resources allocated via DRA.
|
||||
type NodeAllocatableResourceClaimStatusApplyConfiguration struct {
|
||||
// ResourceClaimName is the resource claim referenced by the pod that resulted in this node allocatable resource allocation.
|
||||
ResourceClaimName *string `json:"resourceClaimName,omitempty"`
|
||||
// Containers lists the names of all containers in this pod that reference the claim.
|
||||
Containers []string `json:"containers,omitempty"`
|
||||
// Resources is a map of the node-allocatable resource name to the aggregate quantity allocated to the claim.
|
||||
Resources map[corev1.ResourceName]resource.Quantity `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
// NodeAllocatableResourceClaimStatusApplyConfiguration constructs a declarative configuration of the NodeAllocatableResourceClaimStatus type for use with
|
||||
// apply.
|
||||
func NodeAllocatableResourceClaimStatus() *NodeAllocatableResourceClaimStatusApplyConfiguration {
|
||||
return &NodeAllocatableResourceClaimStatusApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithResourceClaimName sets the ResourceClaimName field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the ResourceClaimName field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceClaimStatusApplyConfiguration) WithResourceClaimName(value string) *NodeAllocatableResourceClaimStatusApplyConfiguration {
|
||||
b.ResourceClaimName = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithContainers adds the given value to the Containers field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the Containers field.
|
||||
func (b *NodeAllocatableResourceClaimStatusApplyConfiguration) WithContainers(values ...string) *NodeAllocatableResourceClaimStatusApplyConfiguration {
|
||||
for i := range values {
|
||||
b.Containers = append(b.Containers, values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithResources puts the entries into the Resources field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the Resources field,
|
||||
// overwriting an existing map entries in Resources field with the same key.
|
||||
func (b *NodeAllocatableResourceClaimStatusApplyConfiguration) WithResources(entries map[corev1.ResourceName]resource.Quantity) *NodeAllocatableResourceClaimStatusApplyConfiguration {
|
||||
if b.Resources == nil && len(entries) > 0 {
|
||||
b.Resources = make(map[corev1.ResourceName]resource.Quantity, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.Resources[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -139,6 +139,12 @@ type PodStatusApplyConfiguration struct {
|
||||
// applied at the pod level if pod-level requests or limits are set in
|
||||
// PodSpec.Resources
|
||||
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
|
||||
// NodeAllocatableResourceClaimStatuses contains the status of node-allocatable resources
|
||||
// that were allocated for this pod through DRA claims. This includes resources currently
|
||||
// reported in v1.Node `status.allocatable` that are not extended resources
|
||||
// (see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#extended-resources).
|
||||
// Examples include "cpu", "memory", "ephemeral-storage", and hugepages.
|
||||
NodeAllocatableResourceClaimStatuses []NodeAllocatableResourceClaimStatusApplyConfiguration `json:"nodeAllocatableResourceClaimStatuses,omitempty"`
|
||||
}
|
||||
|
||||
// PodStatusApplyConfiguration constructs a declarative configuration of the PodStatus type for use with
|
||||
@@ -341,3 +347,16 @@ func (b *PodStatusApplyConfiguration) WithResources(value *ResourceRequirementsA
|
||||
b.Resources = value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithNodeAllocatableResourceClaimStatuses adds the given value to the NodeAllocatableResourceClaimStatuses field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the NodeAllocatableResourceClaimStatuses field.
|
||||
func (b *PodStatusApplyConfiguration) WithNodeAllocatableResourceClaimStatuses(values ...*NodeAllocatableResourceClaimStatusApplyConfiguration) *PodStatusApplyConfiguration {
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithNodeAllocatableResourceClaimStatuses")
|
||||
}
|
||||
b.NodeAllocatableResourceClaimStatuses = append(b.NodeAllocatableResourceClaimStatuses, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -6040,6 +6040,24 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
- name: requiredDuringSchedulingIgnoredDuringExecution
|
||||
type:
|
||||
namedType: io.k8s.api.core.v1.NodeSelector
|
||||
- name: io.k8s.api.core.v1.NodeAllocatableResourceClaimStatus
|
||||
map:
|
||||
fields:
|
||||
- name: containers
|
||||
type:
|
||||
list:
|
||||
elementType:
|
||||
scalar: string
|
||||
elementRelationship: associative
|
||||
- name: resourceClaimName
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: resources
|
||||
type:
|
||||
map:
|
||||
elementType:
|
||||
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
|
||||
- name: io.k8s.api.core.v1.NodeCondition
|
||||
map:
|
||||
fields:
|
||||
@@ -7166,6 +7184,12 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
- name: message
|
||||
type:
|
||||
scalar: string
|
||||
- name: nodeAllocatableResourceClaimStatuses
|
||||
type:
|
||||
list:
|
||||
elementType:
|
||||
namedType: io.k8s.api.core.v1.NodeAllocatableResourceClaimStatus
|
||||
elementRelationship: atomic
|
||||
- name: nominatedNodeName
|
||||
type:
|
||||
scalar: string
|
||||
@@ -12452,6 +12476,11 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: nodeAllocatableResourceMappings
|
||||
type:
|
||||
map:
|
||||
elementType:
|
||||
namedType: io.k8s.api.resource.v1.NodeAllocatableResourceMapping
|
||||
- name: nodeName
|
||||
type:
|
||||
scalar: string
|
||||
@@ -12804,6 +12833,15 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
elementType:
|
||||
scalar: string
|
||||
elementRelationship: atomic
|
||||
- name: io.k8s.api.resource.v1.NodeAllocatableResourceMapping
|
||||
map:
|
||||
fields:
|
||||
- name: allocationMultiplier
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
|
||||
- name: capacityKey
|
||||
type:
|
||||
scalar: string
|
||||
- name: io.k8s.api.resource.v1.OpaqueDeviceConfiguration
|
||||
map:
|
||||
fields:
|
||||
@@ -13136,6 +13174,11 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
elementType:
|
||||
namedType: io.k8s.api.resource.v1beta1.DeviceCounterConsumption
|
||||
elementRelationship: atomic
|
||||
- name: nodeAllocatableResourceMappings
|
||||
type:
|
||||
map:
|
||||
elementType:
|
||||
namedType: io.k8s.api.resource.v1beta1.NodeAllocatableResourceMapping
|
||||
- name: nodeName
|
||||
type:
|
||||
scalar: string
|
||||
@@ -13552,6 +13595,15 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
elementType:
|
||||
scalar: string
|
||||
elementRelationship: atomic
|
||||
- name: io.k8s.api.resource.v1beta1.NodeAllocatableResourceMapping
|
||||
map:
|
||||
fields:
|
||||
- name: allocationMultiplier
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
|
||||
- name: capacityKey
|
||||
type:
|
||||
scalar: string
|
||||
- name: io.k8s.api.resource.v1beta1.OpaqueDeviceConfiguration
|
||||
map:
|
||||
fields:
|
||||
@@ -13877,6 +13929,11 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: nodeAllocatableResourceMappings
|
||||
type:
|
||||
map:
|
||||
elementType:
|
||||
namedType: io.k8s.api.resource.v1beta2.NodeAllocatableResourceMapping
|
||||
- name: nodeName
|
||||
type:
|
||||
scalar: string
|
||||
@@ -14283,6 +14340,15 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
elementType:
|
||||
scalar: string
|
||||
elementRelationship: atomic
|
||||
- name: io.k8s.api.resource.v1beta2.NodeAllocatableResourceMapping
|
||||
map:
|
||||
fields:
|
||||
- name: allocationMultiplier
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
|
||||
- name: capacityKey
|
||||
type:
|
||||
scalar: string
|
||||
- name: io.k8s.api.resource.v1beta2.OpaqueDeviceConfiguration
|
||||
map:
|
||||
fields:
|
||||
|
||||
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
apicorev1 "k8s.io/api/core/v1"
|
||||
resourcev1 "k8s.io/api/resource/v1"
|
||||
corev1 "k8s.io/client-go/applyconfigurations/core/v1"
|
||||
)
|
||||
@@ -113,6 +114,18 @@ type DeviceApplyConfiguration struct {
|
||||
// If AllowMultipleAllocations is set to true, the device can be allocated more than once,
|
||||
// and all of its capacity is consumable, regardless of whether the requestPolicy is defined or not.
|
||||
AllowMultipleAllocations *bool `json:"allowMultipleAllocations,omitempty"`
|
||||
// NodeAllocatableResourceMappings defines the mapping of node resources
|
||||
// that are managed by the DRA driver exposing this device. This includes resources currently
|
||||
// reported in v1.Node `status.allocatable` that are not extended resources
|
||||
// (see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#extended-resources).
|
||||
// Examples include "cpu", "memory", "ephemeral-storage", and hugepages.
|
||||
// In addition to standard requests made through the Pod `spec`, these resources
|
||||
// can also be requested through claims and allocated by the DRA driver.
|
||||
// For example, a CPU DRA driver might allocate exclusive CPUs or auxiliary node memory
|
||||
// dependencies of an accelerator device.
|
||||
// The keys of this map are the node-allocatable resource names (e.g., "cpu", "memory").
|
||||
// Extended resource names are not permitted as keys.
|
||||
NodeAllocatableResourceMappings map[apicorev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration `json:"nodeAllocatableResourceMappings,omitempty"`
|
||||
}
|
||||
|
||||
// DeviceApplyConfiguration constructs a declarative configuration of the Device type for use with
|
||||
@@ -242,3 +255,17 @@ func (b *DeviceApplyConfiguration) WithAllowMultipleAllocations(value bool) *Dev
|
||||
b.AllowMultipleAllocations = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithNodeAllocatableResourceMappings puts the entries into the NodeAllocatableResourceMappings field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the NodeAllocatableResourceMappings field,
|
||||
// overwriting an existing map entries in NodeAllocatableResourceMappings field with the same key.
|
||||
func (b *DeviceApplyConfiguration) WithNodeAllocatableResourceMappings(entries map[apicorev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration) *DeviceApplyConfiguration {
|
||||
if b.NodeAllocatableResourceMappings == nil && len(entries) > 0 {
|
||||
b.NodeAllocatableResourceMappings = make(map[apicorev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.NodeAllocatableResourceMappings[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
resourcev1 "k8s.io/api/resource/v1"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// NodeAllocatableResourceMappingApplyConfiguration represents a declarative configuration of the NodeAllocatableResourceMapping type for use
|
||||
// with apply.
|
||||
//
|
||||
// NodeAllocatableResourceMapping defines the translation between the DRA device/capacity
|
||||
// units requested to the corresponding quantity of the node allocatable resource.
|
||||
type NodeAllocatableResourceMappingApplyConfiguration struct {
|
||||
// CapacityKey references a capacity name defined as a key in the
|
||||
// `spec.devices[*].capacity` map. When this field is set, the value associated with
|
||||
// this key in the `status.allocation.devices.results[*].consumedCapacity` map
|
||||
// (for a specific claim allocation) determines the base quantity for
|
||||
// the node allocatable resource. If `allocationMultiplier` is also set, it is
|
||||
// multiplied with the base quantity.
|
||||
// For example, if `spec.devices[*].capacity` has an entry "dra.example.com/memory": "128Gi",
|
||||
// and this field is set to "dra.example.com/memory", then for a claim allocation
|
||||
// that consumes { "dra.example.com/memory": "4Gi" } the base quantity for the
|
||||
// node allocatable resource mapping will be "4Gi", and `allocationMultiplier` should
|
||||
// be omitted or set to "1".
|
||||
CapacityKey *resourcev1.QualifiedName `json:"capacityKey,omitempty"`
|
||||
// AllocationMultiplier is used as a multiplier for the allocated device count or the allocated capacity in the claim.
|
||||
// It defaults to 1 if not specified. How the field is used also depends on whether `capacityKey` is set.
|
||||
// 1. If `capacityKey` is NOT set: `allocationMultiplier` multiplies the device count allocated to the claim.
|
||||
// a. A DRA driver representing each CPU core as a device would have
|
||||
// {ResourceName: "cpu", allocationMultiplier: "2"} in its
|
||||
// `nodeAllocatableResourceMappings`. If 4 devices are allocated to the claim,
|
||||
// 4 * 2 CPUs would be considered as allocated and subtracted from the node's capacity.
|
||||
// b. A GPU device that needs additional node memory per GPU allocation would
|
||||
// have {ResourceName: "memory", allocationMultiplier: "2Gi"}. Each allocated
|
||||
// GPU device instance of this type will account for 2Gi of memory.
|
||||
//
|
||||
// 2. If `capacityKey` IS set: `allocationMultiplier` is multiplied by the amount of that capacity consumed.
|
||||
// The final node allocatable resource amount is `consumedCapacity[capacityKey]` * `allocationMultiplier`.
|
||||
// For example, if a Device's capacity "dra.example.com/cores" is consumed,
|
||||
// and each "core" provides 2 "cpu"s, the mapping would be:
|
||||
// {ResourceName: "cpu", capacityKey: "dra.example.com/cores", allocationMultiplier: "2"}.
|
||||
// If a claim consumes 8 "dra.example.com/cores", the CPU footprint is 8 * 2 = 16.
|
||||
AllocationMultiplier *resource.Quantity `json:"allocationMultiplier,omitempty"`
|
||||
}
|
||||
|
||||
// NodeAllocatableResourceMappingApplyConfiguration constructs a declarative configuration of the NodeAllocatableResourceMapping type for use with
|
||||
// apply.
|
||||
func NodeAllocatableResourceMapping() *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
return &NodeAllocatableResourceMappingApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithCapacityKey sets the CapacityKey field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the CapacityKey field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceMappingApplyConfiguration) WithCapacityKey(value resourcev1.QualifiedName) *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
b.CapacityKey = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAllocationMultiplier sets the AllocationMultiplier field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the AllocationMultiplier field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceMappingApplyConfiguration) WithAllocationMultiplier(value resource.Quantity) *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
b.AllocationMultiplier = &value
|
||||
return b
|
||||
}
|
||||
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
resourcev1beta1 "k8s.io/api/resource/v1beta1"
|
||||
v1 "k8s.io/client-go/applyconfigurations/core/v1"
|
||||
)
|
||||
@@ -109,6 +110,18 @@ type BasicDeviceApplyConfiguration struct {
|
||||
// If AllowMultipleAllocations is set to true, the device can be allocated more than once,
|
||||
// and all of its capacity is consumable, regardless of whether the requestPolicy is defined or not.
|
||||
AllowMultipleAllocations *bool `json:"allowMultipleAllocations,omitempty"`
|
||||
// NodeAllocatableResourceMappings defines the mapping of node resources
|
||||
// that are managed by the DRA driver exposing this device. This includes resources currently
|
||||
// reported in v1.Node `status.allocatable` that are not extended resources
|
||||
// (see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#extended-resources).
|
||||
// Examples include "cpu", "memory", "ephemeral-storage", and hugepages.
|
||||
// In addition to standard requests made through the Pod `spec`, these resources
|
||||
// can also be requested through claims and allocated by the DRA driver.
|
||||
// For example, a CPU DRA driver might allocate exclusive CPUs or auxiliary node memory
|
||||
// dependencies of an accelerator device.
|
||||
// The keys of this map are the node-allocatable resource names (e.g., "cpu", "memory").
|
||||
// Extended resource names are not permitted as keys.
|
||||
NodeAllocatableResourceMappings map[corev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration `json:"nodeAllocatableResourceMappings,omitempty"`
|
||||
}
|
||||
|
||||
// BasicDeviceApplyConfiguration constructs a declarative configuration of the BasicDevice type for use with
|
||||
@@ -230,3 +243,17 @@ func (b *BasicDeviceApplyConfiguration) WithAllowMultipleAllocations(value bool)
|
||||
b.AllowMultipleAllocations = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithNodeAllocatableResourceMappings puts the entries into the NodeAllocatableResourceMappings field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the NodeAllocatableResourceMappings field,
|
||||
// overwriting an existing map entries in NodeAllocatableResourceMappings field with the same key.
|
||||
func (b *BasicDeviceApplyConfiguration) WithNodeAllocatableResourceMappings(entries map[corev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration) *BasicDeviceApplyConfiguration {
|
||||
if b.NodeAllocatableResourceMappings == nil && len(entries) > 0 {
|
||||
b.NodeAllocatableResourceMappings = make(map[corev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.NodeAllocatableResourceMappings[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
resourcev1beta1 "k8s.io/api/resource/v1beta1"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// NodeAllocatableResourceMappingApplyConfiguration represents a declarative configuration of the NodeAllocatableResourceMapping type for use
|
||||
// with apply.
|
||||
//
|
||||
// NodeAllocatableResourceMapping defines the translation between the DRA device/capacity
|
||||
// units requested to the corresponding quantity of the node allocatable resource.
|
||||
type NodeAllocatableResourceMappingApplyConfiguration struct {
|
||||
// CapacityKey references a capacity name defined as a key in the
|
||||
// `spec.devices[*].capacity` map. When this field is set, the value associated with
|
||||
// this key in the `status.allocation.devices.results[*].consumedCapacity` map
|
||||
// (for a specific claim allocation) determines the base quantity for
|
||||
// the node allocatable resource. If `allocationMultiplier` is also set, it is
|
||||
// multiplied with the base quantity.
|
||||
// For example, if `spec.devices[*].capacity` has an entry "dra.example.com/memory": "128Gi",
|
||||
// and this field is set to "dra.example.com/memory", then for a claim allocation
|
||||
// that consumes { "dra.example.com/memory": "4Gi" } the base quantity for the
|
||||
// node allocatable resource mapping will be "4Gi", and `allocationMultiplier` should
|
||||
// be omitted or set to "1".
|
||||
CapacityKey *resourcev1beta1.QualifiedName `json:"capacityKey,omitempty"`
|
||||
// AllocationMultiplier is used as a multiplier for the allocated device count or the allocated capacity in the claim.
|
||||
// It defaults to 1 if not specified. How the field is used also depends on whether `capacityKey` is set.
|
||||
// 1. If `capacityKey` is NOT set: `allocationMultiplier` multiplies the device count allocated to the claim.
|
||||
// a. A DRA driver representing each CPU core as a device would have
|
||||
// {ResourceName: "cpu", allocationMultiplier: "2"} in its
|
||||
// `nodeAllocatableResourceMappings`. If 4 devices are allocated to the claim,
|
||||
// 4 * 2 CPUs would be considered as allocated and subtracted from the node's capacity.
|
||||
// b. A GPU device that needs additional node memory per GPU allocation would
|
||||
// have {ResourceName: "memory", allocationMultiplier: "2Gi"}. Each allocated
|
||||
// GPU device instance of this type will account for 2Gi of memory.
|
||||
//
|
||||
// 2. If `capacityKey` IS set: `allocationMultiplier` is multiplied by the amount of that capacity consumed.
|
||||
// The final node allocatable resource amount is `consumedCapacity[capacityKey]` * `allocationMultiplier`.
|
||||
// For example, if a Device's capacity "dra.example.com/cores" is consumed,
|
||||
// and each "core" provides 2 "cpu"s, the mapping would be:
|
||||
// {ResourceName: "cpu", capacityKey: "dra.example.com/cores", allocationMultiplier: "2"}.
|
||||
// If a claim consumes 8 "dra.example.com/cores", the CPU footprint is 8 * 2 = 16.
|
||||
AllocationMultiplier *resource.Quantity `json:"allocationMultiplier,omitempty"`
|
||||
}
|
||||
|
||||
// NodeAllocatableResourceMappingApplyConfiguration constructs a declarative configuration of the NodeAllocatableResourceMapping type for use with
|
||||
// apply.
|
||||
func NodeAllocatableResourceMapping() *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
return &NodeAllocatableResourceMappingApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithCapacityKey sets the CapacityKey field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the CapacityKey field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceMappingApplyConfiguration) WithCapacityKey(value resourcev1beta1.QualifiedName) *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
b.CapacityKey = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAllocationMultiplier sets the AllocationMultiplier field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the AllocationMultiplier field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceMappingApplyConfiguration) WithAllocationMultiplier(value resource.Quantity) *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
b.AllocationMultiplier = &value
|
||||
return b
|
||||
}
|
||||
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
package v1beta2
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
resourcev1beta2 "k8s.io/api/resource/v1beta2"
|
||||
v1 "k8s.io/client-go/applyconfigurations/core/v1"
|
||||
)
|
||||
@@ -113,6 +114,18 @@ type DeviceApplyConfiguration struct {
|
||||
// If AllowMultipleAllocations is set to true, the device can be allocated more than once,
|
||||
// and all of its capacity is consumable, regardless of whether the requestPolicy is defined or not.
|
||||
AllowMultipleAllocations *bool `json:"allowMultipleAllocations,omitempty"`
|
||||
// NodeAllocatableResourceMappings defines the mapping of node resources
|
||||
// that are managed by the DRA driver exposing this device. This includes resources currently
|
||||
// reported in v1.Node `status.allocatable` that are not extended resources
|
||||
// (see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#extended-resources).
|
||||
// Examples include "cpu", "memory", "ephemeral-storage", and hugepages.
|
||||
// In addition to standard requests made through the Pod `spec`, these resources
|
||||
// can also be requested through claims and allocated by the DRA driver.
|
||||
// For example, a CPU DRA driver might allocate exclusive CPUs or auxiliary node memory
|
||||
// dependencies of an accelerator device.
|
||||
// The keys of this map are the node-allocatable resource names (e.g., "cpu", "memory").
|
||||
// Extended resource names are not permitted as keys.
|
||||
NodeAllocatableResourceMappings map[corev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration `json:"nodeAllocatableResourceMappings,omitempty"`
|
||||
}
|
||||
|
||||
// DeviceApplyConfiguration constructs a declarative configuration of the Device type for use with
|
||||
@@ -242,3 +255,17 @@ func (b *DeviceApplyConfiguration) WithAllowMultipleAllocations(value bool) *Dev
|
||||
b.AllowMultipleAllocations = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithNodeAllocatableResourceMappings puts the entries into the NodeAllocatableResourceMappings field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the NodeAllocatableResourceMappings field,
|
||||
// overwriting an existing map entries in NodeAllocatableResourceMappings field with the same key.
|
||||
func (b *DeviceApplyConfiguration) WithNodeAllocatableResourceMappings(entries map[corev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration) *DeviceApplyConfiguration {
|
||||
if b.NodeAllocatableResourceMappings == nil && len(entries) > 0 {
|
||||
b.NodeAllocatableResourceMappings = make(map[corev1.ResourceName]NodeAllocatableResourceMappingApplyConfiguration, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.NodeAllocatableResourceMappings[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta2
|
||||
|
||||
import (
|
||||
resourcev1beta2 "k8s.io/api/resource/v1beta2"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// NodeAllocatableResourceMappingApplyConfiguration represents a declarative configuration of the NodeAllocatableResourceMapping type for use
|
||||
// with apply.
|
||||
//
|
||||
// NodeAllocatableResourceMapping defines the translation between the DRA device/capacity
|
||||
// units requested to the corresponding quantity of the node allocatable resource.
|
||||
type NodeAllocatableResourceMappingApplyConfiguration struct {
|
||||
// CapacityKey references a capacity name defined as a key in the
|
||||
// `spec.devices[*].capacity` map. When this field is set, the value associated with
|
||||
// this key in the `status.allocation.devices.results[*].consumedCapacity` map
|
||||
// (for a specific claim allocation) determines the base quantity for
|
||||
// the node allocatable resource. If `allocationMultiplier` is also set, it is
|
||||
// multiplied with the base quantity.
|
||||
// For example, if `spec.devices[*].capacity` has an entry "dra.example.com/memory": "128Gi",
|
||||
// and this field is set to "dra.example.com/memory", then for a claim allocation
|
||||
// that consumes { "dra.example.com/memory": "4Gi" } the base quantity for the
|
||||
// node allocatable resource mapping will be "4Gi", and `allocationMultiplier` should
|
||||
// be omitted or set to "1".
|
||||
CapacityKey *resourcev1beta2.QualifiedName `json:"capacityKey,omitempty"`
|
||||
// AllocationMultiplier is used as a multiplier for the allocated device count or the allocated capacity in the claim.
|
||||
// It defaults to 1 if not specified. How the field is used also depends on whether `capacityKey` is set.
|
||||
// 1. If `capacityKey` is NOT set: `allocationMultiplier` multiplies the device count allocated to the claim.
|
||||
// a. A DRA driver representing each CPU core as a device would have
|
||||
// {ResourceName: "cpu", allocationMultiplier: "2"} in its
|
||||
// `nodeAllocatableResourceMappings`. If 4 devices are allocated to the claim,
|
||||
// 4 * 2 CPUs would be considered as allocated and subtracted from the node's capacity.
|
||||
// b. A GPU device that needs additional node memory per GPU allocation would
|
||||
// have {ResourceName: "memory", allocationMultiplier: "2Gi"}. Each allocated
|
||||
// GPU device instance of this type will account for 2Gi of memory.
|
||||
//
|
||||
// 2. If `capacityKey` IS set: `allocationMultiplier` is multiplied by the amount of that capacity consumed.
|
||||
// The final node allocatable resource amount is `consumedCapacity[capacityKey]` * `allocationMultiplier`.
|
||||
// For example, if a Device's capacity "dra.example.com/cores" is consumed,
|
||||
// and each "core" provides 2 "cpu"s, the mapping would be:
|
||||
// {ResourceName: "cpu", capacityKey: "dra.example.com/cores", allocationMultiplier: "2"}.
|
||||
// If a claim consumes 8 "dra.example.com/cores", the CPU footprint is 8 * 2 = 16.
|
||||
AllocationMultiplier *resource.Quantity `json:"allocationMultiplier,omitempty"`
|
||||
}
|
||||
|
||||
// NodeAllocatableResourceMappingApplyConfiguration constructs a declarative configuration of the NodeAllocatableResourceMapping type for use with
|
||||
// apply.
|
||||
func NodeAllocatableResourceMapping() *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
return &NodeAllocatableResourceMappingApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithCapacityKey sets the CapacityKey field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the CapacityKey field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceMappingApplyConfiguration) WithCapacityKey(value resourcev1beta2.QualifiedName) *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
b.CapacityKey = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAllocationMultiplier sets the AllocationMultiplier field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the AllocationMultiplier field is set to the value of the last call.
|
||||
func (b *NodeAllocatableResourceMappingApplyConfiguration) WithAllocationMultiplier(value resource.Quantity) *NodeAllocatableResourceMappingApplyConfiguration {
|
||||
b.AllocationMultiplier = &value
|
||||
return b
|
||||
}
|
||||
@@ -790,6 +790,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
return &applyconfigurationscorev1.NodeAddressApplyConfiguration{}
|
||||
case corev1.SchemeGroupVersion.WithKind("NodeAffinity"):
|
||||
return &applyconfigurationscorev1.NodeAffinityApplyConfiguration{}
|
||||
case corev1.SchemeGroupVersion.WithKind("NodeAllocatableResourceClaimStatus"):
|
||||
return &applyconfigurationscorev1.NodeAllocatableResourceClaimStatusApplyConfiguration{}
|
||||
case corev1.SchemeGroupVersion.WithKind("NodeCondition"):
|
||||
return &applyconfigurationscorev1.NodeConditionApplyConfiguration{}
|
||||
case corev1.SchemeGroupVersion.WithKind("NodeConfigSource"):
|
||||
@@ -1620,6 +1622,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
return &applyconfigurationsresourcev1.ExactDeviceRequestApplyConfiguration{}
|
||||
case resourcev1.SchemeGroupVersion.WithKind("NetworkDeviceData"):
|
||||
return &applyconfigurationsresourcev1.NetworkDeviceDataApplyConfiguration{}
|
||||
case resourcev1.SchemeGroupVersion.WithKind("NodeAllocatableResourceMapping"):
|
||||
return &applyconfigurationsresourcev1.NodeAllocatableResourceMappingApplyConfiguration{}
|
||||
case resourcev1.SchemeGroupVersion.WithKind("OpaqueDeviceConfiguration"):
|
||||
return &applyconfigurationsresourcev1.OpaqueDeviceConfigurationApplyConfiguration{}
|
||||
case resourcev1.SchemeGroupVersion.WithKind("ResourceClaim"):
|
||||
@@ -1712,6 +1716,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
return &applyconfigurationsresourcev1beta1.DeviceTolerationApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("NetworkDeviceData"):
|
||||
return &applyconfigurationsresourcev1beta1.NetworkDeviceDataApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("NodeAllocatableResourceMapping"):
|
||||
return &applyconfigurationsresourcev1beta1.NodeAllocatableResourceMappingApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("OpaqueDeviceConfiguration"):
|
||||
return &applyconfigurationsresourcev1beta1.OpaqueDeviceConfigurationApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("ResourceClaim"):
|
||||
@@ -1800,6 +1806,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
return &applyconfigurationsresourcev1beta2.ExactDeviceRequestApplyConfiguration{}
|
||||
case resourcev1beta2.SchemeGroupVersion.WithKind("NetworkDeviceData"):
|
||||
return &applyconfigurationsresourcev1beta2.NetworkDeviceDataApplyConfiguration{}
|
||||
case resourcev1beta2.SchemeGroupVersion.WithKind("NodeAllocatableResourceMapping"):
|
||||
return &applyconfigurationsresourcev1beta2.NodeAllocatableResourceMappingApplyConfiguration{}
|
||||
case resourcev1beta2.SchemeGroupVersion.WithKind("OpaqueDeviceConfiguration"):
|
||||
return &applyconfigurationsresourcev1beta2.OpaqueDeviceConfigurationApplyConfiguration{}
|
||||
case resourcev1beta2.SchemeGroupVersion.WithKind("ResourceClaim"):
|
||||
|
||||
2
go.mod
2
go.mod
@@ -23,7 +23,7 @@ require (
|
||||
golang.org/x/time v0.14.0
|
||||
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af
|
||||
gopkg.in/evanphx/json-patch.v4 v4.13.0
|
||||
k8s.io/api v0.0.0-20260318195839-1ee4dbfb376b
|
||||
k8s.io/api v0.0.0-20260318235847-50328df638da
|
||||
k8s.io/apimachinery v0.0.0-20260318195418-729062d58854
|
||||
k8s.io/klog/v2 v2.140.0
|
||||
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a
|
||||
|
||||
4
go.sum
4
go.sum
@@ -105,8 +105,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/api v0.0.0-20260318195839-1ee4dbfb376b h1:vJ68uqHpPb2e0gBRYOYD1iKivPg5rq9ERpcClN5tbb4=
|
||||
k8s.io/api v0.0.0-20260318195839-1ee4dbfb376b/go.mod h1:Me8XWRAAY/34t+2YTLQeaWCLaH9DHxkNCTqVHMwo3lg=
|
||||
k8s.io/api v0.0.0-20260318235847-50328df638da h1:+OhUIVeMDF6qQp4PDPxIr/UYNKjbekhGfmM+wDDJvzU=
|
||||
k8s.io/api v0.0.0-20260318235847-50328df638da/go.mod h1:Me8XWRAAY/34t+2YTLQeaWCLaH9DHxkNCTqVHMwo3lg=
|
||||
k8s.io/apimachinery v0.0.0-20260318195418-729062d58854 h1:iuI2iZc7u7hgHcDS8SzYRurcIo3ltRh4MnFkCTYmV2c=
|
||||
k8s.io/apimachinery v0.0.0-20260318195418-729062d58854/go.mod h1:Fjag9BypDOzB4sV3iuZaNeDsRkf89asmbm8aWLerfeU=
|
||||
k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc=
|
||||
|
||||
Reference in New Issue
Block a user