Skip to content

Commit a7bbf14

Browse files
committed
Make .spec.authSecret in NemoGuardRail optional
Signed-off-by: Sheng Lin <shelin@nvidia.com>
1 parent 6122fdf commit a7bbf14

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

api/apps/v1alpha1/nemo_guardrails_types.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ type NemoGuardrailSpec struct {
5757
Command []string `json:"command,omitempty"`
5858
Args []string `json:"args,omitempty"`
5959
Env []corev1.EnvVar `json:"env,omitempty"`
60-
// The name of an secret that contains authn for the NGC NIM service API
61-
AuthSecret string `json:"authSecret"`
60+
// The name of an secret that contains authn for the NGC NIM service API, required when the NIM is hosted by NGC
61+
AuthSecret *string `json:"authSecret,omitempty"`
6262
// ConfigStore stores the config of the guardrail service
6363
ConfigStore GuardrailConfig `json:"configStore,omitempty"`
6464
Labels map[string]string `json:"labels,omitempty"`
@@ -187,19 +187,21 @@ func (n *NemoGuardrail) GetStandardEnv() []corev1.EnvVar {
187187
Name: "DEMO",
188188
Value: "False",
189189
},
190-
{
190+
}
191+
192+
if n.Spec.AuthSecret != nil && len(*n.Spec.AuthSecret) > 0 {
193+
envVars = append(envVars, corev1.EnvVar{
191194
Name: "NIM_ENDPOINT_API_KEY",
192195
ValueFrom: &corev1.EnvVarSource{
193196
SecretKeyRef: &corev1.SecretKeySelector{
194197
Key: "nim-endpoint-api-key",
195198
LocalObjectReference: corev1.LocalObjectReference{
196-
Name: n.Spec.AuthSecret,
199+
Name: *n.Spec.AuthSecret,
197200
},
198201
},
199202
},
200-
},
203+
})
201204
}
202-
203205
return envVars
204206
}
205207

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 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_nemoguardrails.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ spec:
5757
type: array
5858
authSecret:
5959
description: The name of an secret that contains authn for the NGC
60-
NIM service API
60+
NIM service API, required when the NIM is hosted by NGC
6161
type: string
6262
command:
6363
items:
@@ -2204,7 +2204,6 @@ spec:
22042204
format: int64
22052205
type: integer
22062206
required:
2207-
- authSecret
22082207
- expose
22092208
- image
22102209
type: object

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ spec:
5757
type: array
5858
authSecret:
5959
description: The name of an secret that contains authn for the NGC
60-
NIM service API
60+
NIM service API, required when the NIM is hosted by NGC
6161
type: string
6262
command:
6363
items:
@@ -2204,7 +2204,6 @@ spec:
22042204
format: int64
22052205
type: integer
22062206
required:
2207-
- authSecret
22082207
- expose
22092208
- image
22102209
type: object

deployments/helm/k8s-nim-operator/crds/apps.nvidia.com_nemoguardrails.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ spec:
5757
type: array
5858
authSecret:
5959
description: The name of an secret that contains authn for the NGC
60-
NIM service API
60+
NIM service API, required when the NIM is hosted by NGC
6161
type: string
6262
command:
6363
items:
@@ -2204,7 +2204,6 @@ spec:
22042204
format: int64
22052205
type: integer
22062206
required:
2207-
- authSecret
22082207
- expose
22092208
- image
22102209
type: object

0 commit comments

Comments
 (0)