Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions api/apps/v1alpha1/dra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
//
// When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
// that uniquely identifies the DRA resource.
// +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."
// +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."
type DRAResource struct {
// ResourceClaimName is the name of a DRA resource claim object in the same
// namespace as the NIMService.
Expand All @@ -57,10 +57,11 @@ type DRAResource struct {
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*`
ResourceClaimTemplateName *string `json:"resourceClaimTemplateName,omitempty"`

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

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

// DRAClaimSpec defines the spec for generating a DRA resource claim/resource claim template.
type DRAClaimSpec struct {
// GenerateName is an optional name prefix to use for generating the resource claim/resource claim template.
// DRAClaimCreationSpec defines the spec for generating a DRA resource claim template.
type DRAClaimCreationSpec struct {
// GenerateName is an optional name prefix to use for generating the resource claim template.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=16
GenerateName string `json:"generateName,omitempty"`
// +kubebuilder:validation:MinSize=1
Devices []DRADeviceSpec `json:"devices"`
// TODO: Warn that if set to false, then this NIMService cannot be scaled up.
IsTemplate *bool `json:"isTemplate,omitempty"`
}

func (d *DRAClaimSpec) IsTemplateSpec() bool {
return d.IsTemplate != nil && *d.IsTemplate
}

func (d *DRAClaimSpec) GetNamePrefix() string {
func (d *DRAClaimCreationSpec) GetNamePrefix() string {
namePrefix := d.GenerateName
if namePrefix != "" {
return namePrefix
}
if d.IsTemplateSpec() {
return "claimtemplate"
}
return "claim"
return "claimtemplate"
}

// DRAResourceStatus defines the status of the DRAResource.
Expand Down
19 changes: 7 additions & 12 deletions api/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 10 additions & 12 deletions bundle/manifests/apps.nvidia.com_nimpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@ spec:
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
that uniquely identifies the DRA resource.
properties:
claimSpec:
description: ClaimSpec is the spec to auto-generate
a DRA resource claim/resource claim template. Only
one of ClaimSpec, ResourceClaimName or ResourceClaimTemplateName
must be specified.
claimCreationSpec:
description: |-
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
properties:
devices:
items:
Expand Down Expand Up @@ -274,19 +273,17 @@ spec:
type: array
generateName:
description: GenerateName is an optional name
prefix to use for generating the resource claim/resource
claim template.
prefix to use for generating the resource claim
template.
maxLength: 16
minLength: 1
type: string
isTemplate:
type: boolean
required:
- devices
type: object
requests:
description: |-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
Requests is the list of requests in the referenced DRA resource claim.
to be made available to the model container of the NIMService pods.

If empty, everything from the claim is made available, otherwise
Expand Down Expand Up @@ -323,9 +320,10 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
or spec.claimSpec must be set.
or spec.claimCreationSpec must be set.
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) ==
1'
type: array
env:
items:
Expand Down
18 changes: 8 additions & 10 deletions bundle/manifests/apps.nvidia.com_nimservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ spec:
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
that uniquely identifies the DRA resource.
properties:
claimSpec:
description: ClaimSpec is the spec to auto-generate a DRA resource
claim/resource claim template. Only one of ClaimSpec, ResourceClaimName
or ResourceClaimTemplateName must be specified.
claimCreationSpec:
description: |-
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
properties:
devices:
items:
Expand Down Expand Up @@ -225,18 +225,16 @@ spec:
type: array
generateName:
description: GenerateName is an optional name prefix to
use for generating the resource claim/resource claim template.
use for generating the resource claim template.
maxLength: 16
minLength: 1
type: string
isTemplate:
type: boolean
required:
- devices
type: object
requests:
description: |-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
Requests is the list of requests in the referenced DRA resource claim.
to be made available to the model container of the NIMService pods.

If empty, everything from the claim is made available, otherwise
Expand Down Expand Up @@ -273,9 +271,9 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
or spec.claimSpec must be set.
or spec.claimCreationSpec must be set.
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) == 1'
type: array
env:
items:
Expand Down
22 changes: 10 additions & 12 deletions config/crd/bases/apps.nvidia.com_nimpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@ spec:
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
that uniquely identifies the DRA resource.
properties:
claimSpec:
description: ClaimSpec is the spec to auto-generate
a DRA resource claim/resource claim template. Only
one of ClaimSpec, ResourceClaimName or ResourceClaimTemplateName
must be specified.
claimCreationSpec:
description: |-
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
properties:
devices:
items:
Expand Down Expand Up @@ -274,19 +273,17 @@ spec:
type: array
generateName:
description: GenerateName is an optional name
prefix to use for generating the resource claim/resource
claim template.
prefix to use for generating the resource claim
template.
maxLength: 16
minLength: 1
type: string
isTemplate:
type: boolean
required:
- devices
type: object
requests:
description: |-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
Requests is the list of requests in the referenced DRA resource claim.
to be made available to the model container of the NIMService pods.

If empty, everything from the claim is made available, otherwise
Expand Down Expand Up @@ -323,9 +320,10 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
or spec.claimSpec must be set.
or spec.claimCreationSpec must be set.
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) ==
1'
type: array
env:
items:
Expand Down
18 changes: 8 additions & 10 deletions config/crd/bases/apps.nvidia.com_nimservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ spec:
When creating the NIMService pods, it adds a name (`DNS_LABEL` format) to it
that uniquely identifies the DRA resource.
properties:
claimSpec:
description: ClaimSpec is the spec to auto-generate a DRA resource
claim/resource claim template. Only one of ClaimSpec, ResourceClaimName
or ResourceClaimTemplateName must be specified.
claimCreationSpec:
description: |-
ClaimCreationSpec is the spec to auto-generate a DRA resource claim template.
Only one of ClaimCreationSpec, ResourceClaimName or ResourceClaimTemplateName must be specified.
properties:
devices:
items:
Expand Down Expand Up @@ -225,18 +225,16 @@ spec:
type: array
generateName:
description: GenerateName is an optional name prefix to
use for generating the resource claim/resource claim template.
use for generating the resource claim template.
maxLength: 16
minLength: 1
type: string
isTemplate:
type: boolean
required:
- devices
type: object
requests:
description: |-
Requests is the list of requests in the referenced DRA resource claim/resource claim template
Requests is the list of requests in the referenced DRA resource claim.
to be made available to the model container of the NIMService pods.

If empty, everything from the claim is made available, otherwise
Expand Down Expand Up @@ -273,9 +271,9 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of spec.resourceClaimName, spec.resourceClaimTemplateName,
or spec.claimSpec must be set.
or spec.claimCreationSpec must be set.
rule: '(has(self.resourceClaimName) ? 1 : 0) + (has(self.resourceClaimTemplateName)
? 1 : 0) + (has(self.claimSpec) ? 1 : 0) == 1'
? 1 : 0) + (has(self.claimCreationSpec) ? 1 : 0) == 1'
type: array
env:
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
profile: ''
replicas: 1
draResources:
- claimSpec:
- claimCreationSpec:
devices:
- name: gpu
expose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ spec:
profile: ''
replicas: 1
draResources:
- claimSpec:
isTemplate: true
- claimCreationSpec:
devices:
- name: gpu
deviceClassName: gpu.nvidia.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ spec:
profile: ''
replicas: 1
draResources:
- claimSpec:
isTemplate: true
- claimCreationSpec:
devices:
- name: gpu
deviceClassName: gpu.nvidia.com
driverName: gpu.nvidia.com
celExpressions:
- (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)
expose:
service:
type: ClusterIP
port: 8000
Loading
Loading