@@ -275,17 +275,6 @@ func (n *NIMService) GetStandardEnv() []corev1.EnvVar {
275275 Name : "NIM_CACHE_PATH" ,
276276 Value : utils .DefaultModelStorePath ,
277277 },
278- {
279- Name : "NGC_API_KEY" ,
280- ValueFrom : & corev1.EnvVarSource {
281- SecretKeyRef : & corev1.SecretKeySelector {
282- LocalObjectReference : corev1.LocalObjectReference {
283- Name : n .Spec .AuthSecret ,
284- },
285- Key : "NGC_API_KEY" ,
286- },
287- },
288- },
289278 {
290279 Name : "OUTLINES_CACHE_DIR" ,
291280 Value : "/tmp/outlines" ,
@@ -362,6 +351,11 @@ func (n *NIMService) getLWSCommonEnv() []corev1.EnvVar {
362351 return env
363352}
364353
354+ // GetLWSLeaderEnvFrom returns the env from sources for the leader worker set.
355+ func (n * NIMService ) GetLWSCommonEnvFrom () []corev1.EnvFromSource {
356+ return n .GetEnvFrom ()
357+ }
358+
365359func (n * NIMService ) GetLWSLeaderEnv () []corev1.EnvVar {
366360 env := n .getLWSCommonEnv ()
367361
@@ -566,6 +560,23 @@ func (n *NIMService) GetEnv() []corev1.EnvVar {
566560 return envVarList
567561}
568562
563+ // GetEnvFrom returns merged slice of standard and user specified env from sources.
564+ func (n * NIMService ) GetEnvFrom () []corev1.EnvFromSource {
565+ if n .Spec .AuthSecret != "" {
566+ return []corev1.EnvFromSource {
567+ {
568+ SecretRef : & corev1.SecretEnvSource {
569+ LocalObjectReference : corev1.LocalObjectReference {
570+ Name : n .Spec .AuthSecret ,
571+ },
572+ },
573+ },
574+ }
575+ }
576+ // no secrets to source the env variables
577+ return []corev1.EnvFromSource {}
578+ }
579+
569580// GetImage returns container image for the NIMService.
570581func (n * NIMService ) GetImage () string {
571582 return fmt .Sprintf ("%s:%s" , n .Spec .Image .Repository , n .Spec .Image .Tag )
@@ -1047,6 +1058,7 @@ func (n *NIMService) GetDeploymentParams() *rendertypes.DeploymentParams {
10471058 // Set container spec
10481059 params .ContainerName = n .GetContainerName ()
10491060 params .Env = n .GetEnv ()
1061+ params .EnvFrom = n .GetEnvFrom ()
10501062 params .Args = n .GetArgs ()
10511063 params .Command = n .GetCommand ()
10521064 params .Resources = n .GetResources ()
@@ -1118,6 +1130,8 @@ func (n *NIMService) GetLWSParams() *rendertypes.LeaderWorkerSetParams {
11181130 params .Command = n .GetCommand ()
11191131 params .LeaderEnvs = n .GetLWSLeaderEnv ()
11201132 params .WorkerEnvs = n .GetLWSWorkerEnv ()
1133+ params .LeaderEnvFrom = n .GetLWSCommonEnvFrom ()
1134+ params .WorkerEnvFrom = n .GetLWSCommonEnvFrom ()
11211135 params .UserID = n .GetUserID ()
11221136 params .GroupID = n .GetGroupID ()
11231137 params .Image = n .GetImage ()
0 commit comments