Skip to content

Commit f81be88

Browse files
authored
only autocreate dra claim templates (#627)
* only autocreate dra claim templates Signed-off-by: Varun Ramachandra Sekar <vsekar@nvidia.com>
1 parent 5c43dbb commit f81be88

File tree

20 files changed

+191
-385
lines changed

20 files changed

+191
-385
lines changed

api/apps/v1alpha1/dra_types.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
//
3131
// When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
3232
// that uniquely identifies the DRA resource.
33-
// +kubebuilder:validation:XValidation:rule="(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName) ? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1",message="exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName, or spec.claimSpec must be set."
33+
// +kubebuilder:validation:XValidation:rule="(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName) ? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) == 1",message="exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName, or spec.claimCreationSpec must be set."
3434
type DRAResource struct {
3535
// ResourceClaimName is the name of a DRA resource claim object in the same
3636
// namespace as the NIMService.
@@ -57,10 +57,11 @@ type DRAResource struct {
5757
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*`
5858
ResourceClaimTemplateName *string `json:"resourceClaimTemplateName,omitempty"`
5959

60-
// ClaimSpec is the spec to auto-generate a DRA resource claim/resource claim template. Only one of ClaimSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
61-
ClaimSpec *DRAClaimSpec `json:"claimSpec,omitempty"`
60+
// ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
61+
// Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
62+
ClaimCreationSpec *DRAClaimCreationSpec `json:"claimCreationSpec,omitempty"`
6263

63-
// Requests is the list of requests in the referenced DRA resource claim/resource claim template
64+
// Requests is the list of requests in the referenced DRA resource claim.
6465
// to be made available to the model container of the NIMService pods.
6566
//
6667
// If empty, everything from the claim is made available, otherwise
@@ -247,31 +248,23 @@ type DRADeviceSpec struct {
247248
CELExpressions []string `json:"celExpressions,omitempty"`
248249
}
249250

250-
// DRAClaimSpec defines the spec for generating a DRA resource claim/resource claim template.
251-
type DRAClaimSpec struct {
252-
// GenerateName is an optional name prefix to use for generating the resource claim/resource claim template.
251+
// DRAClaimCreationSpec defines the spec for generating a DRA resource claim template.
252+
type DRAClaimCreationSpec struct {
253+
// GenerateName is an optional name prefix to use for generating the resource claim template.
254+
//
253255
// +kubebuilder:validation:MinLength=1
254256
// +kubebuilder:validation:MaxLength=16
255257
GenerateName string `json:"generateName,omitempty"`
256258
// +kubebuilder:validation:MinSize=1
257259
Devices []DRADeviceSpec `json:"devices"`
258-
// TODO: Warn that if set to false, then this NIMService cannot be scaled up.
259-
IsTemplate *bool `json:"isTemplate,omitempty"`
260-
}
261-
262-
func (d *DRAClaimSpec) IsTemplateSpec() bool {
263-
return d.IsTemplate != nil && *d.IsTemplate
264260
}
265261

266-
func (d *DRAClaimSpec) GetNamePrefix() string {
262+
func (d *DRAClaimCreationSpec) GetNamePrefix() string {
267263
namePrefix := d.GenerateName
268264
if namePrefix != "" {
269265
return namePrefix
270266
}
271-
if d.IsTemplateSpec() {
272-
return "claimtemplate"
273-
}
274-
return "claim"
267+
return "claimtemplate"
275268
}
276269

277270
// DRAResourceStatus defines the status of the DRAResource.

api/apps/v1alpha1/zz_generated.deepcopy.go

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

bundle/manifests/apps.nvidia.com_nimpipelines.yaml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ spec:
113113
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
114114
that uniquely identifies the DRA resource.
115115
properties:
116-
claimSpec:
117-
description: ClaimSpec is the spec to auto-generate
118-
a DRA resource claim/resource claim template. Only
119-
one of ClaimSpec, ResourceClaimName or ResourceClaimTemplateName
120-
must be specified.
116+
claimCreationSpec:
117+
description: |-
118+
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
119+
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
121120
properties:
122121
devices:
123122
items:
@@ -274,19 +273,17 @@ spec:
274273
type: array
275274
generateName:
276275
description: GenerateName is an optional name
277-
prefix to use for generating the resource claim/resource
278-
claim template.
276+
prefix to use for generating the resource claim
277+
template.
279278
maxLength: 16
280279
minLength: 1
281280
type: string
282-
isTemplate:
283-
type: boolean
284281
required:
285282
- devices
286283
type: object
287284
requests:
288285
description: |-
289-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
286+
Requests is the list of requests in the referenced DRA resource claim.
290287
to be made available to the model container of the NIMService pods.
291288
292289
If empty, everything from the claim is made available, otherwise
@@ -323,9 +320,10 @@ spec:
323320
type: object
324321
x-kubernetes-validations:
325322
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
326-
or spec.claimSpec must be set.
323+
or spec.claimCreationSpec must be set.
327324
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
328-
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
325+
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) ==
326+
1'
329327
type: array
330328
env:
331329
items:

bundle/manifests/apps.nvidia.com_nimservices.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ spec:
7373
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
7474
that uniquely identifies the DRA resource.
7575
properties:
76-
claimSpec:
77-
description: ClaimSpec is the spec to auto-generate a DRA resource
78-
claim/resource claim template. Only one of ClaimSpec, ResourceClaimName
79-
or ResourceClaimTemplateName must be specified.
76+
claimCreationSpec:
77+
description: |-
78+
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
79+
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
8080
properties:
8181
devices:
8282
items:
@@ -225,18 +225,16 @@ spec:
225225
type: array
226226
generateName:
227227
description: GenerateName is an optional name prefix to
228-
use for generating the resource claim/resource claim template.
228+
use for generating the resource claim template.
229229
maxLength: 16
230230
minLength: 1
231231
type: string
232-
isTemplate:
233-
type: boolean
234232
required:
235233
- devices
236234
type: object
237235
requests:
238236
description: |-
239-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
237+
Requests is the list of requests in the referenced DRA resource claim.
240238
to be made available to the model container of the NIMService pods.
241239
242240
If empty, everything from the claim is made available, otherwise
@@ -273,9 +271,9 @@ spec:
273271
type: object
274272
x-kubernetes-validations:
275273
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
276-
or spec.claimSpec must be set.
274+
or spec.claimCreationSpec must be set.
277275
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
278-
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
276+
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) == 1'
279277
type: array
280278
env:
281279
items:

config/crd/bases/apps.nvidia.com_nimpipelines.yaml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ spec:
113113
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
114114
that uniquely identifies the DRA resource.
115115
properties:
116-
claimSpec:
117-
description: ClaimSpec is the spec to auto-generate
118-
a DRA resource claim/resource claim template. Only
119-
one of ClaimSpec, ResourceClaimName or ResourceClaimTemplateName
120-
must be specified.
116+
claimCreationSpec:
117+
description: |-
118+
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
119+
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
121120
properties:
122121
devices:
123122
items:
@@ -274,19 +273,17 @@ spec:
274273
type: array
275274
generateName:
276275
description: GenerateName is an optional name
277-
prefix to use for generating the resource claim/resource
278-
claim template.
276+
prefix to use for generating the resource claim
277+
template.
279278
maxLength: 16
280279
minLength: 1
281280
type: string
282-
isTemplate:
283-
type: boolean
284281
required:
285282
- devices
286283
type: object
287284
requests:
288285
description: |-
289-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
286+
Requests is the list of requests in the referenced DRA resource claim.
290287
to be made available to the model container of the NIMService pods.
291288
292289
If empty, everything from the claim is made available, otherwise
@@ -323,9 +320,10 @@ spec:
323320
type: object
324321
x-kubernetes-validations:
325322
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
326-
or spec.claimSpec must be set.
323+
or spec.claimCreationSpec must be set.
327324
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
328-
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
325+
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) ==
326+
1'
329327
type: array
330328
env:
331329
items:

config/crd/bases/apps.nvidia.com_nimservices.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ spec:
7373
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
7474
that uniquely identifies the DRA resource.
7575
properties:
76-
claimSpec:
77-
description: ClaimSpec is the spec to auto-generate a DRA resource
78-
claim/resource claim template. Only one of ClaimSpec, ResourceClaimName
79-
or ResourceClaimTemplateName must be specified.
76+
claimCreationSpec:
77+
description: |-
78+
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
79+
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
8080
properties:
8181
devices:
8282
items:
@@ -225,18 +225,16 @@ spec:
225225
type: array
226226
generateName:
227227
description: GenerateName is an optional name prefix to
228-
use for generating the resource claim/resource claim template.
228+
use for generating the resource claim template.
229229
maxLength: 16
230230
minLength: 1
231231
type: string
232-
isTemplate:
233-
type: boolean
234232
required:
235233
- devices
236234
type: object
237235
requests:
238236
description: |-
239-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
237+
Requests is the list of requests in the referenced DRA resource claim.
240238
to be made available to the model container of the NIMService pods.
241239
242240
If empty, everything from the claim is made available, otherwise
@@ -273,9 +271,9 @@ spec:
273271
type: object
274272
x-kubernetes-validations:
275273
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
276-
or spec.claimSpec must be set.
274+
or spec.claimCreationSpec must be set.
277275
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
278-
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
276+
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) == 1'
279277
type: array
280278
env:
281279
items:

config/samples/nim/llm/dra-auto-creation/example0/nimservice.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
profile: ''
1717
replicas: 1
1818
draResources:
19-
- claimSpec:
19+
- claimCreationSpec:
2020
devices:
2121
- name: gpu
2222
expose:

config/samples/nim/llm/dra-auto-creation/example1/nimservice.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ spec:
1616
profile: ''
1717
replicas: 1
1818
draResources:
19-
- claimSpec:
20-
isTemplate: true
19+
- claimCreationSpec:
2120
devices:
2221
- name: gpu
2322
deviceClassName: gpu.nvidia.com

config/samples/nim/llm/dra-auto-creation/example2/nimservice.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ spec:
1616
profile: ''
1717
replicas: 1
1818
draResources:
19-
- claimSpec:
20-
isTemplate: true
19+
- claimCreationSpec:
2120
devices:
2221
- name: gpu
2322
deviceClassName: gpu.nvidia.com
2423
driverName: gpu.nvidia.com
2524
celExpressions:
2625
- (device.attributes["gpu.nvidia.com"].productName.lowerAscii().matches("^.*a100.*$") && device.capacity["gpu.nvidia.com"].memory.compareTo(quantity("40Gi")) >= 0) || (device.attributes["gpu.nvidia.com"].productName.lowerAscii().matches("^.*h100.*$") && device.attributes["gpu.nvidia.com"].driverVersion.compareTo(semver("550.127.8")) >= 0)
26+
expose:
2727
service:
2828
type: ClusterIP
2929
port: 8000

0 commit comments

Comments
 (0)