Skip to content

Commit ba137b4

Browse files
shivamerlavisheshtanksale
authored andcommitted
Allow setting PVC annotations while creation (#518)
Signed-off-by: Shiva Krishna, Merla <smerla@nvidia.com> Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com>
1 parent 4a4ac8f commit ba137b4

22 files changed

+342
-59
lines changed

api/apps/v1alpha1/common_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,25 @@ type NGCSecret struct {
217217
// +kubebuilder:default:="NGC_API_KEY"
218218
Key string `json:"key"`
219219
}
220+
221+
// PersistentVolumeClaim defines the attributes of PVC.
222+
// +kubebuilder:validation:XValidation:rule="!has(self.create) || !self.create || (has(self.size) && self.size != \"\")", message="size is required for pvc creation"
223+
// +kubebuilder:validation:XValidation:rule="!has(self.create) || !self.create || (has(self.volumeAccessMode) && self.volumeAccessMode != \"\")", message="volumeAccessMode is required for pvc creation"
224+
type PersistentVolumeClaim struct {
225+
// Create specifies whether to create a new PersistentVolumeClaim (PVC).
226+
// If set to false, an existing PVC must be referenced via the `Name` field.
227+
Create *bool `json:"create,omitempty"`
228+
// Name of the PVC to use. Required if `Create` is false (i.e., using an existing PVC).
229+
Name string `json:"name,omitempty"`
230+
// StorageClass to be used for PVC creation. Leave it as empty if the PVC is already created or
231+
// a default storage class is set in the cluster.
232+
StorageClass string `json:"storageClass,omitempty"`
233+
// Size of the NIM cache in Gi, used during PVC creation
234+
Size string `json:"size,omitempty"`
235+
// VolumeAccessMode is the volume access mode of the PVC
236+
VolumeAccessMode corev1.PersistentVolumeAccessMode `json:"volumeAccessMode,omitempty"`
237+
// SubPath is the path inside the PVC that should be mounted
238+
SubPath string `json:"subPath,omitempty"`
239+
// Annotations for the PVC
240+
Annotations map[string]string `json:"annotations,omitempty"`
241+
}

api/apps/v1alpha1/nimcache_types.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,6 @@ type NIMCacheStorage struct {
156156
HostPath *string `json:"hostPath,omitempty"`
157157
}
158158

159-
// PersistentVolumeClaim defines the attributes of PVC used as a source for caching NIM model.
160-
type PersistentVolumeClaim struct {
161-
// Create indicates to create a new PVC
162-
Create *bool `json:"create,omitempty"`
163-
// Name is the name of the PVC
164-
Name string `json:"name,omitempty"`
165-
// StorageClass to be used for PVC creation. Leave it as empty if the PVC is already created or
166-
// a default storage class is set in the cluster.
167-
StorageClass string `json:"storageClass,omitempty"`
168-
// Size of the NIM cache in Gi, used during PVC creation
169-
Size string `json:"size,omitempty"`
170-
// VolumeAccessMode is the volume access mode of the PVC
171-
VolumeAccessMode corev1.PersistentVolumeAccessMode `json:"volumeAccessMode,omitempty"`
172-
// SubPath is the path inside the PVC that should be mounted
173-
SubPath string `json:"subPath,omitempty"`
174-
}
175-
176159
// NIMCacheStatus defines the observed state of NIMCache.
177160
type NIMCacheStatus struct {
178161
State string `json:"state,omitempty"`

api/apps/v1alpha1/zz_generated.deepcopy.go

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

bundle/manifests/apps.nvidia.com_nemocustomizers.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,11 +1974,19 @@ spec:
19741974
description: ModelPVC is the persistent storage for models used
19751975
for finetuning
19761976
properties:
1977+
annotations:
1978+
additionalProperties:
1979+
type: string
1980+
description: Annotations for the PVC
1981+
type: object
19771982
create:
1978-
description: Create indicates to create a new PVC
1983+
description: |-
1984+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
1985+
If set to false, an existing PVC must be referenced via the `Name` field.
19791986
type: boolean
19801987
name:
1981-
description: Name is the name of the PVC
1988+
description: Name of the PVC to use. Required if `Create`
1989+
is false (i.e., using an existing PVC).
19821990
type: string
19831991
size:
19841992
description: Size of the NIM cache in Gi, used during PVC
@@ -1998,6 +2006,13 @@ spec:
19982006
the PVC
19992007
type: string
20002008
type: object
2009+
x-kubernetes-validations:
2010+
- message: size is required for pvc creation
2011+
rule: '!has(self.create) || !self.create || (has(self.size)
2012+
&& self.size != "")'
2013+
- message: volumeAccessMode is required for pvc creation
2014+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
2015+
&& self.volumeAccessMode != "")'
20012016
networkConfig:
20022017
description: NetworkConfig is the network configuration for multi-node
20032018
training

bundle/manifests/apps.nvidia.com_nemodatastores.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,19 @@ spec:
788788
pvc:
789789
description: PVC defines the PersistentVolumeClaim for the datastore
790790
properties:
791+
annotations:
792+
additionalProperties:
793+
type: string
794+
description: Annotations for the PVC
795+
type: object
791796
create:
792-
description: Create indicates to create a new PVC
797+
description: |-
798+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
799+
If set to false, an existing PVC must be referenced via the `Name` field.
793800
type: boolean
794801
name:
795-
description: Name is the name of the PVC
802+
description: Name of the PVC to use. Required if `Create` is false
803+
(i.e., using an existing PVC).
796804
type: string
797805
size:
798806
description: Size of the NIM cache in Gi, used during PVC creation
@@ -811,6 +819,13 @@ spec:
811819
PVC
812820
type: string
813821
type: object
822+
x-kubernetes-validations:
823+
- message: size is required for pvc creation
824+
rule: '!has(self.create) || !self.create || (has(self.size) && self.size
825+
!= "")'
826+
- message: volumeAccessMode is required for pvc creation
827+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
828+
&& self.volumeAccessMode != "")'
814829
replicas:
815830
default: 1
816831
minimum: 1

bundle/manifests/apps.nvidia.com_nemoguardrails.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,21 @@ spec:
7272
- name
7373
type: object
7474
pvc:
75-
description: PersistentVolumeClaim defines the attributes of PVC
76-
used as a source for caching NIM model.
75+
description: PersistentVolumeClaim defines the attributes of PVC.
7776
properties:
77+
annotations:
78+
additionalProperties:
79+
type: string
80+
description: Annotations for the PVC
81+
type: object
7882
create:
79-
description: Create indicates to create a new PVC
83+
description: |-
84+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
85+
If set to false, an existing PVC must be referenced via the `Name` field.
8086
type: boolean
8187
name:
82-
description: Name is the name of the PVC
88+
description: Name of the PVC to use. Required if `Create`
89+
is false (i.e., using an existing PVC).
8390
type: string
8491
size:
8592
description: Size of the NIM cache in Gi, used during PVC
@@ -99,6 +106,13 @@ spec:
99106
the PVC
100107
type: string
101108
type: object
109+
x-kubernetes-validations:
110+
- message: size is required for pvc creation
111+
rule: '!has(self.create) || !self.create || (has(self.size)
112+
&& self.size != "")'
113+
- message: volumeAccessMode is required for pvc creation
114+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
115+
&& self.volumeAccessMode != "")'
102116
type: object
103117
x-kubernetes-validations:
104118
- message: Cannot set both ConfigMap and PVC in ConfigStore

bundle/manifests/apps.nvidia.com_nimcaches.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,19 @@ spec:
420420
description: PersistentVolumeClaim is the pvc volume used for
421421
caching NIM
422422
properties:
423+
annotations:
424+
additionalProperties:
425+
type: string
426+
description: Annotations for the PVC
427+
type: object
423428
create:
424-
description: Create indicates to create a new PVC
429+
description: |-
430+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
431+
If set to false, an existing PVC must be referenced via the `Name` field.
425432
type: boolean
426433
name:
427-
description: Name is the name of the PVC
434+
description: Name of the PVC to use. Required if `Create`
435+
is false (i.e., using an existing PVC).
428436
type: string
429437
size:
430438
description: Size of the NIM cache in Gi, used during PVC
@@ -444,6 +452,13 @@ spec:
444452
the PVC
445453
type: string
446454
type: object
455+
x-kubernetes-validations:
456+
- message: size is required for pvc creation
457+
rule: '!has(self.create) || !self.create || (has(self.size)
458+
&& self.size != "")'
459+
- message: volumeAccessMode is required for pvc creation
460+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
461+
&& self.volumeAccessMode != "")'
447462
type: object
448463
tolerations:
449464
description: Tolerations for running the job to cache the NIM model

bundle/manifests/apps.nvidia.com_nimpipelines.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,11 +2194,19 @@ spec:
21942194
description: PersistentVolumeClaim is the pvc volume
21952195
used for caching NIM
21962196
properties:
2197+
annotations:
2198+
additionalProperties:
2199+
type: string
2200+
description: Annotations for the PVC
2201+
type: object
21972202
create:
2198-
description: Create indicates to create a new PVC
2203+
description: |-
2204+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
2205+
If set to false, an existing PVC must be referenced via the `Name` field.
21992206
type: boolean
22002207
name:
2201-
description: Name is the name of the PVC
2208+
description: Name of the PVC to use. Required if
2209+
`Create` is false (i.e., using an existing PVC).
22022210
type: string
22032211
size:
22042212
description: Size of the NIM cache in Gi, used during
@@ -2218,6 +2226,13 @@ spec:
22182226
mode of the PVC
22192227
type: string
22202228
type: object
2229+
x-kubernetes-validations:
2230+
- message: size is required for pvc creation
2231+
rule: '!has(self.create) || !self.create || (has(self.size)
2232+
&& self.size != "")'
2233+
- message: volumeAccessMode is required for pvc creation
2234+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
2235+
&& self.volumeAccessMode != "")'
22212236
readOnly:
22222237
description: ReadOnly mode indicates if the volume should
22232238
be mounted as read-only

bundle/manifests/apps.nvidia.com_nimservices.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,11 +2110,19 @@ spec:
21102110
description: PersistentVolumeClaim is the pvc volume used for
21112111
caching NIM
21122112
properties:
2113+
annotations:
2114+
additionalProperties:
2115+
type: string
2116+
description: Annotations for the PVC
2117+
type: object
21132118
create:
2114-
description: Create indicates to create a new PVC
2119+
description: |-
2120+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
2121+
If set to false, an existing PVC must be referenced via the `Name` field.
21152122
type: boolean
21162123
name:
2117-
description: Name is the name of the PVC
2124+
description: Name of the PVC to use. Required if `Create`
2125+
is false (i.e., using an existing PVC).
21182126
type: string
21192127
size:
21202128
description: Size of the NIM cache in Gi, used during PVC
@@ -2134,6 +2142,13 @@ spec:
21342142
the PVC
21352143
type: string
21362144
type: object
2145+
x-kubernetes-validations:
2146+
- message: size is required for pvc creation
2147+
rule: '!has(self.create) || !self.create || (has(self.size)
2148+
&& self.size != "")'
2149+
- message: volumeAccessMode is required for pvc creation
2150+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
2151+
&& self.volumeAccessMode != "")'
21372152
readOnly:
21382153
description: ReadOnly mode indicates if the volume should be mounted
21392154
as read-only

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,11 +1974,19 @@ spec:
19741974
description: ModelPVC is the persistent storage for models used
19751975
for finetuning
19761976
properties:
1977+
annotations:
1978+
additionalProperties:
1979+
type: string
1980+
description: Annotations for the PVC
1981+
type: object
19771982
create:
1978-
description: Create indicates to create a new PVC
1983+
description: |-
1984+
Create specifies whether to create a new PersistentVolumeClaim (PVC).
1985+
If set to false, an existing PVC must be referenced via the `Name` field.
19791986
type: boolean
19801987
name:
1981-
description: Name is the name of the PVC
1988+
description: Name of the PVC to use. Required if `Create`
1989+
is false (i.e., using an existing PVC).
19821990
type: string
19831991
size:
19841992
description: Size of the NIM cache in Gi, used during PVC
@@ -1998,6 +2006,13 @@ spec:
19982006
the PVC
19992007
type: string
20002008
type: object
2009+
x-kubernetes-validations:
2010+
- message: size is required for pvc creation
2011+
rule: '!has(self.create) || !self.create || (has(self.size)
2012+
&& self.size != "")'
2013+
- message: volumeAccessMode is required for pvc creation
2014+
rule: '!has(self.create) || !self.create || (has(self.volumeAccessMode)
2015+
&& self.volumeAccessMode != "")'
20012016
networkConfig:
20022017
description: NetworkConfig is the network configuration for multi-node
20032018
training

0 commit comments

Comments
 (0)