Skip to content

Commit 779f3b1

Browse files
Adding support for emptydir on NIMService (#701)
* Adding support for emptydir on NIMService Signed-off-by: Vishesh Tanksale <[email protected]> * Addressing review comments Signed-off-by: Vishesh Tanksale <[email protected]> --------- Signed-off-by: Vishesh Tanksale <[email protected]>
1 parent f371b97 commit 779f3b1

24 files changed

+158
-41
lines changed

api/apps/v1alpha1/nimservice_types.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ type NIMServiceStorage struct {
228228
HostPath *string `json:"hostPath,omitempty"`
229229
// ReadOnly mode indicates if the volume should be mounted as read-only
230230
ReadOnly *bool `json:"readOnly,omitempty"`
231+
// EmptyDir is the empty dir volume used for caching NIM
232+
EmptyDir *EmptyDirSpec `json:"emptyDir,omitempty"`
233+
}
234+
235+
type EmptyDirSpec struct {
236+
// SizeLimit is the size limit of the empty dir volume
237+
SizeLimit *resource.Quantity `json:"sizeLimit,omitempty"`
231238
}
232239

233240
// GetLWSName returns the name to be used for the LeaderWorkerSet based on the custom spec.
@@ -700,7 +707,7 @@ func (n *NIMService) GetVolumesMounts() []corev1.Volume {
700707
}
701708

702709
// GetVolumes returns volumes for the NIMService container.
703-
func (n *NIMService) GetVolumes(modelPVC PersistentVolumeClaim) []corev1.Volume {
710+
func (n *NIMService) GetVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume {
704711
// TODO: Fetch actual PVC name from associated NIMCache obj
705712
volumes := []corev1.Volume{
706713
{
@@ -712,15 +719,26 @@ func (n *NIMService) GetVolumes(modelPVC PersistentVolumeClaim) []corev1.Volume
712719
},
713720
},
714721
},
715-
{
722+
}
723+
if modelPVC != nil {
724+
volumes = append(volumes, corev1.Volume{
716725
Name: "model-store",
717726
VolumeSource: corev1.VolumeSource{
718727
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
719728
ClaimName: modelPVC.Name,
720729
ReadOnly: n.GetStorageReadOnly(),
721730
},
722731
},
723-
},
732+
})
733+
} else if n.Spec.Storage.EmptyDir != nil {
734+
volumes = append(volumes, corev1.Volume{
735+
Name: "model-store",
736+
VolumeSource: corev1.VolumeSource{
737+
EmptyDir: &corev1.EmptyDirVolumeSource{
738+
SizeLimit: n.Spec.Storage.EmptyDir.SizeLimit,
739+
},
740+
},
741+
})
724742
}
725743

726744
if n.GetProxySpec() != nil {
@@ -729,7 +747,7 @@ func (n *NIMService) GetVolumes(modelPVC PersistentVolumeClaim) []corev1.Volume
729747
return volumes
730748
}
731749

732-
func (n *NIMService) GetLeaderVolumes(modelPVC PersistentVolumeClaim) []corev1.Volume {
750+
func (n *NIMService) GetLeaderVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume {
733751
volumes := n.GetVolumes(modelPVC)
734752

735753
volumes = append(volumes,
@@ -774,7 +792,7 @@ func (n *NIMService) GetLeaderVolumes(modelPVC PersistentVolumeClaim) []corev1.V
774792
return volumes
775793
}
776794

777-
func (n *NIMService) GetWorkerVolumes(modelPVC PersistentVolumeClaim) []corev1.Volume {
795+
func (n *NIMService) GetWorkerVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume {
778796
volumes := n.GetVolumes(modelPVC)
779797
volumes = append(volumes,
780798
corev1.Volume{
@@ -814,12 +832,16 @@ func (n *NIMService) GetWorkerVolumes(modelPVC PersistentVolumeClaim) []corev1.V
814832
}
815833

816834
// GetVolumeMounts returns volumes for the NIMService container.
817-
func (n *NIMService) GetVolumeMounts(modelPVC PersistentVolumeClaim) []corev1.VolumeMount {
835+
func (n *NIMService) GetVolumeMounts(modelPVC *PersistentVolumeClaim) []corev1.VolumeMount {
836+
subPath := ""
837+
if modelPVC != nil {
838+
subPath = modelPVC.SubPath
839+
}
818840
volumeMounts := []corev1.VolumeMount{
819841
{
820842
Name: "model-store",
821843
MountPath: "/model-store",
822-
SubPath: modelPVC.SubPath,
844+
SubPath: subPath,
823845
},
824846
{
825847
Name: "dshm",
@@ -833,7 +855,7 @@ func (n *NIMService) GetVolumeMounts(modelPVC PersistentVolumeClaim) []corev1.Vo
833855
return volumeMounts
834856
}
835857

836-
func (n *NIMService) GetWorkerVolumeMounts(modelPVC PersistentVolumeClaim) []corev1.VolumeMount {
858+
func (n *NIMService) GetWorkerVolumeMounts(modelPVC *PersistentVolumeClaim) []corev1.VolumeMount {
837859
volumeMounts := n.GetVolumeMounts(modelPVC)
838860

839861
volumeMounts = append(volumeMounts,
@@ -858,7 +880,7 @@ func (n *NIMService) GetWorkerVolumeMounts(modelPVC PersistentVolumeClaim) []cor
858880
return volumeMounts
859881
}
860882

861-
func (n *NIMService) GetLeaderVolumeMounts(modelPVC PersistentVolumeClaim) []corev1.VolumeMount {
883+
func (n *NIMService) GetLeaderVolumeMounts(modelPVC *PersistentVolumeClaim) []corev1.VolumeMount {
862884
volumeMounts := n.GetVolumeMounts(modelPVC)
863885
volumeMounts = append(volumeMounts,
864886
corev1.VolumeMount{

api/apps/v1alpha1/nimservice_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestGetVolumes(t *testing.T) {
110110

111111
for _, tt := range tests {
112112
t.Run(tt.name, func(t *testing.T) {
113-
vols := tt.nimService.GetVolumes(tt.modelPVC)
113+
vols := tt.nimService.GetVolumes(&tt.modelPVC)
114114
if !reflect.DeepEqual(vols, tt.desired) {
115115
t.Errorf("GetVolumes() = %v, want %v", vols, tt.desired)
116116
}

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 25 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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,6 @@ spec:
20512051
x-kubernetes-list-type: atomic
20522052
type: object
20532053
replicas:
2054-
default: 1
20552054
format: int32
20562055
minimum: 1
20572056
type: integer

bundle/manifests/apps.nvidia.com_nemodatastores.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,6 @@ spec:
17301730
type: string
17311731
type: object
17321732
replicas:
1733-
default: 1
17341733
format: int32
17351734
minimum: 1
17361735
type: integer

bundle/manifests/apps.nvidia.com_nemoentitystores.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,6 @@ spec:
16601660
x-kubernetes-list-type: atomic
16611661
type: object
16621662
replicas:
1663-
default: 1
16641663
format: int32
16651664
minimum: 1
16661665
type: integer

bundle/manifests/apps.nvidia.com_nemoevaluators.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,6 @@ spec:
17961796
x-kubernetes-list-type: atomic
17971797
type: object
17981798
replicas:
1799-
default: 1
18001799
format: int32
18011800
minimum: 1
18021801
type: integer

bundle/manifests/apps.nvidia.com_nemoguardrails.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,6 @@ spec:
17841784
x-kubernetes-list-type: atomic
17851785
type: object
17861786
replicas:
1787-
default: 1
17881787
format: int32
17891788
minimum: 1
17901789
type: integer

bundle/manifests/apps.nvidia.com_nimcaches.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ spec:
5454
description: |-
5555
CertConfig is the name of the ConfigMap containing the custom certificates.
5656
for secure communication.
57+
5758
Deprecated: use `Proxy` instead to configure custom certificates for using proxy.
5859
properties:
5960
mountPath:

bundle/manifests/apps.nvidia.com_nimpipelines.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,6 @@ spec:
25232523
type: object
25242524
type: object
25252525
replicas:
2526-
default: 1
25272526
format: int32
25282527
minimum: 1
25292528
type: integer
@@ -3483,6 +3482,19 @@ spec:
34833482
description: Storage is the target storage for caching NIM
34843483
model if NIMCache is not provided
34853484
properties:
3485+
emptyDir:
3486+
description: EmptyDir is the empty dir volume used for
3487+
caching NIM
3488+
properties:
3489+
sizeLimit:
3490+
anyOf:
3491+
- type: integer
3492+
- type: string
3493+
description: SizeLimit is the size limit of the
3494+
empty dir volume
3495+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
3496+
x-kubernetes-int-or-string: true
3497+
type: object
34863498
hostPath:
34873499
description: HostPath is the host path volume for caching
34883500
NIM

0 commit comments

Comments
 (0)