@@ -499,6 +499,8 @@ func (n *NIMService) GetStandardAnnotations() map[string]string {
499499 }
500500 if n .GetProxyCertConfigMap () != "" {
501501 standardAnnotations ["openshift.io/required-scc" ] = "anyuid"
502+ } else if n .GetHostPath () != "" {
503+ standardAnnotations ["openshift.io/required-scc" ] = "hostmount-anyuid"
502504 }
503505 return standardAnnotations
504506}
@@ -709,7 +711,8 @@ func (n *NIMService) GetVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume
709711 },
710712 },
711713 }
712- if modelPVC != nil {
714+ switch {
715+ case modelPVC != nil :
713716 volumes = append (volumes , corev1.Volume {
714717 Name : "model-store" ,
715718 VolumeSource : corev1.VolumeSource {
@@ -719,7 +722,7 @@ func (n *NIMService) GetVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume
719722 },
720723 },
721724 })
722- } else if n .Spec .Storage .EmptyDir != nil {
725+ case n .Spec .Storage .EmptyDir != nil :
723726 volumes = append (volumes , corev1.Volume {
724727 Name : "model-store" ,
725728 VolumeSource : corev1.VolumeSource {
@@ -728,6 +731,17 @@ func (n *NIMService) GetVolumes(modelPVC *PersistentVolumeClaim) []corev1.Volume
728731 },
729732 },
730733 })
734+ case n .GetHostPath () != "" :
735+ hostPathType := corev1 .HostPathDirectoryOrCreate
736+ volumes = append (volumes , corev1.Volume {
737+ Name : "model-store" ,
738+ VolumeSource : corev1.VolumeSource {
739+ HostPath : & corev1.HostPathVolumeSource {
740+ Path : * n .Spec .Storage .HostPath ,
741+ Type : & hostPathType ,
742+ },
743+ },
744+ })
731745 }
732746
733747 if n .GetProxyCertConfigMap () != "" {
@@ -1417,7 +1431,8 @@ func (n *NIMService) GetRoleParams() *rendertypes.RoleParams {
14171431 params .Namespace = n .GetNamespace ()
14181432
14191433 // Set rules to use SCC
1420- if n .GetProxySpec () != nil {
1434+ switch {
1435+ case n .GetProxySpec () != nil :
14211436 params .Rules = []rbacv1.PolicyRule {
14221437 {
14231438 APIGroups : []string {"security.openshift.io" },
@@ -1426,7 +1441,16 @@ func (n *NIMService) GetRoleParams() *rendertypes.RoleParams {
14261441 Verbs : []string {"use" },
14271442 },
14281443 }
1429- } else {
1444+ case n .GetHostPath () != "" :
1445+ params .Rules = []rbacv1.PolicyRule {
1446+ {
1447+ APIGroups : []string {"security.openshift.io" },
1448+ Resources : []string {"securitycontextconstraints" },
1449+ ResourceNames : []string {"hostmount-anyuid" },
1450+ Verbs : []string {"use" },
1451+ },
1452+ }
1453+ default :
14301454 params .Rules = []rbacv1.PolicyRule {
14311455 {
14321456 APIGroups : []string {"security.openshift.io" },
@@ -1591,6 +1615,14 @@ func (n *NIMService) GetProxyCertConfigMap() string {
15911615 return ""
15921616}
15931617
1618+ // GetHostPath returns the host path for the NIMService deployment.
1619+ func (n * NIMService ) GetHostPath () string {
1620+ if n .Spec .Storage .HostPath != nil && * n .Spec .Storage .HostPath != "" {
1621+ return * n .Spec .Storage .HostPath
1622+ }
1623+ return ""
1624+ }
1625+
15941626// GetInferenceServiceParams returns params to render InferenceService from templates.
15951627func (n * NIMService ) GetInferenceServiceParams (
15961628 deploymentMode kserveconstants.DeploymentModeType ) * rendertypes.InferenceServiceParams {
0 commit comments