Skip to content

Commit 2d81c9c

Browse files
pkg/configmap: add upstream resource transformations support
Add Resources field to KueueConfiguration to expose upstream Kueue's resource transformation feature. This allows users to configure resource exclusions and transformations (Replace/Retain strategies) via the operator CR. Signed-off-by: Sohan Kunkerkar <[email protected]>
1 parent fce2cba commit 2d81c9c

File tree

8 files changed

+278
-0
lines changed

8 files changed

+278
-0
lines changed

bundle/manifests/kueue.openshift.io_kueues.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,48 @@ spec:
271271
required:
272272
- preemptionPolicy
273273
type: object
274+
resources:
275+
description: |-
276+
resources controls how Kueue manages resource transformations.
277+
Resource transformations allow converting PodSpec resources into Workload resource requests.
278+
This field is optional.
279+
properties:
280+
excludeResourcePrefixes:
281+
description: ExcludedResourcePrefixes defines which resources
282+
should be ignored by Kueue
283+
items:
284+
type: string
285+
type: array
286+
transformations:
287+
description: |-
288+
Transformations defines how to transform PodSpec resources into Workload resource requests.
289+
This is intended to be a map with Input as the key (enforced by validation code)
290+
items:
291+
properties:
292+
input:
293+
description: Input is the name of the input resource.
294+
type: string
295+
outputs:
296+
additionalProperties:
297+
anyOf:
298+
- type: integer
299+
- type: string
300+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
301+
x-kubernetes-int-or-string: true
302+
description: |-
303+
Outputs specifies the output resources and quantities per unit of input resource.
304+
An empty Outputs combined with a `Replace` Strategy causes the Input resource to be ignored by Kueue.
305+
type: object
306+
strategy:
307+
description: |-
308+
Strategy specifies if the input resource should be replaced or retained.
309+
Defaults to Retain
310+
type: string
311+
required:
312+
- input
313+
type: object
314+
type: array
315+
type: object
274316
workloadManagement:
275317
description: |-
276318
workloadManagement controls how Kueue manages workloads.

deploy/crd/kueue-operator.crd.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,48 @@ spec:
271271
required:
272272
- preemptionPolicy
273273
type: object
274+
resources:
275+
description: |-
276+
resources controls how Kueue manages resource transformations.
277+
Resource transformations allow converting PodSpec resources into Workload resource requests.
278+
This field is optional.
279+
properties:
280+
excludeResourcePrefixes:
281+
description: ExcludedResourcePrefixes defines which resources
282+
should be ignored by Kueue
283+
items:
284+
type: string
285+
type: array
286+
transformations:
287+
description: |-
288+
Transformations defines how to transform PodSpec resources into Workload resource requests.
289+
This is intended to be a map with Input as the key (enforced by validation code)
290+
items:
291+
properties:
292+
input:
293+
description: Input is the name of the input resource.
294+
type: string
295+
outputs:
296+
additionalProperties:
297+
anyOf:
298+
- type: integer
299+
- type: string
300+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
301+
x-kubernetes-int-or-string: true
302+
description: |-
303+
Outputs specifies the output resources and quantities per unit of input resource.
304+
An empty Outputs combined with a `Replace` Strategy causes the Input resource to be ignored by Kueue.
305+
type: object
306+
strategy:
307+
description: |-
308+
Strategy specifies if the input resource should be replaced or retained.
309+
Defaults to Retain
310+
type: string
311+
required:
312+
- input
313+
type: object
314+
type: array
315+
type: object
274316
workloadManagement:
275317
description: |-
276318
workloadManagement controls how Kueue manages workloads.

manifests/kueue.openshift.io_kueues.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,48 @@ spec:
271271
required:
272272
- preemptionPolicy
273273
type: object
274+
resources:
275+
description: |-
276+
resources controls how Kueue manages resource transformations.
277+
Resource transformations allow converting PodSpec resources into Workload resource requests.
278+
This field is optional.
279+
properties:
280+
excludeResourcePrefixes:
281+
description: ExcludedResourcePrefixes defines which resources
282+
should be ignored by Kueue
283+
items:
284+
type: string
285+
type: array
286+
transformations:
287+
description: |-
288+
Transformations defines how to transform PodSpec resources into Workload resource requests.
289+
This is intended to be a map with Input as the key (enforced by validation code)
290+
items:
291+
properties:
292+
input:
293+
description: Input is the name of the input resource.
294+
type: string
295+
outputs:
296+
additionalProperties:
297+
anyOf:
298+
- type: integer
299+
- type: string
300+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
301+
x-kubernetes-int-or-string: true
302+
description: |-
303+
Outputs specifies the output resources and quantities per unit of input resource.
304+
An empty Outputs combined with a `Replace` Strategy causes the Input resource to be ignored by Kueue.
305+
type: object
306+
strategy:
307+
description: |-
308+
Strategy specifies if the input resource should be replaced or retained.
309+
Defaults to Retain
310+
type: string
311+
required:
312+
- input
313+
type: object
314+
type: array
315+
type: object
274316
workloadManagement:
275317
description: |-
276318
workloadManagement controls how Kueue manages workloads.

pkg/apis/kueueoperator/v1/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1
33
import (
44
operatorv1 "github.com/openshift/api/operator/v1"
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
configapi "sigs.k8s.io/kueue/apis/config/v1beta1"
67
)
78

89
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -70,6 +71,11 @@ type KueueConfiguration struct {
7071
// This default could change over time.
7172
// +optional
7273
Preemption Preemption `json:"preemption"`
74+
// resources controls how Kueue manages resource transformations.
75+
// Resource transformations allow converting PodSpec resources into Workload resource requests.
76+
// This field is optional.
77+
// +optional
78+
Resources *configapi.Resources `json:"resources,omitempty"`
7379
}
7480

7581
// KueueStatus defines the observed state of Kueue

pkg/apis/kueueoperator/v1/zz_generated.deepcopy.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/configmap/configmap.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ func buildFairSharing(preemption kueue.Preemption) *configapi.FairSharing {
136136
}
137137
}
138138

139+
func buildResources(resources *configapi.Resources) *configapi.Resources {
140+
return resources
141+
}
142+
139143
func defaultKueueConfigurationTemplate(kueueCfg kueue.KueueConfiguration) *configapi.Configuration {
140144
return &configapi.Configuration{
141145
TypeMeta: v1.TypeMeta{
@@ -193,6 +197,7 @@ func defaultKueueConfigurationTemplate(kueueCfg kueue.KueueConfiguration) *confi
193197
ManageJobsWithoutQueueName: buildManagedJobsWithoutQueueName(kueueCfg.WorkloadManagement),
194198
WaitForPodsReady: buildWaitForPodsReady(kueueCfg.GangScheduling),
195199
FairSharing: buildFairSharing(kueueCfg.Preemption),
200+
Resources: buildResources(kueueCfg.Resources),
196201
}
197202
}
198203

0 commit comments

Comments
 (0)