Skip to content

Commit f162148

Browse files
Adding support for hostpath on NIMService
Signed-off-by: Vishesh Tanksale <[email protected]>
1 parent 7350000 commit f162148

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

api/apps/v1alpha1/nimservice_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,17 @@ func (n *NIMService) GetVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume
728728
},
729729
},
730730
})
731+
} else if n.Spec.Storage.HostPath != nil && *n.Spec.Storage.HostPath != "" {
732+
hostPathType := corev1.HostPathDirectoryOrCreate
733+
volumes = append(volumes, corev1.Volume{
734+
Name: "model-store",
735+
VolumeSource: corev1.VolumeSource{
736+
HostPath: &corev1.HostPathVolumeSource{
737+
Path: *n.Spec.Storage.HostPath,
738+
Type: &hostPathType,
739+
},
740+
},
741+
})
731742
}
732743

733744
if n.GetProxyCertConfigMap() != "" {

internal/controller/platform/kserve/nimservice.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,11 @@ func (r *NIMServiceReconciler) renderAndSyncCache(ctx context.Context,
342342
modelPVC = &nimService.Spec.Storage.PVC
343343
} else if nimService.Spec.Storage.EmptyDir != nil {
344344
modelPVC = nil
345+
} else if nimService.Spec.Storage.HostPath != nil && *nimService.Spec.Storage.HostPath != "" {
346+
modelPVC = nil
345347
} else {
346-
err := fmt.Errorf("neither external PVC name or NIMCache volume is provided")
347-
logger.Error(err, "failed to determine PVC for model-store")
348+
err := fmt.Errorf("neither external PVC name, NIMCache volume, empty dir or local host path should be provided")
349+
logger.Error(err, "failed to determine PVC , NIMCache volume, empty dir or local host path for model-store")
348350
return nil, "", nil, err
349351
}
350352

internal/controller/platform/standalone/nimservice.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,11 @@ func (r *NIMServiceReconciler) reconcileNIMService(ctx context.Context, nimServi
372372
modelPVC = &nimService.Spec.Storage.PVC
373373
} else if nimService.Spec.Storage.EmptyDir != nil {
374374
modelPVC = nil
375+
} else if nimService.Spec.Storage.HostPath != nil && *nimService.Spec.Storage.HostPath != "" {
376+
modelPVC = nil
375377
} else {
376-
err = fmt.Errorf("neither external PVC name, NIMCache volume or empty dir is provided")
377-
logger.Error(err, "failed to determine PVC , NIMCache volume or empty dir for model-store")
378+
err = fmt.Errorf("neither external PVC name, NIMCache volume, empty dir or local host path should be provided")
379+
logger.Error(err, "failed to determine PVC , NIMCache volume, empty dir or local host path for model-store")
378380
return ctrl.Result{}, err
379381
}
380382

0 commit comments

Comments
 (0)