Skip to content

Commit 70dfee2

Browse files
Fixing Eval implementation (#300)
Signed-off-by: Vishesh Tanksale <[email protected]>
1 parent 4e0745e commit 70dfee2

11 files changed

+263
-125
lines changed

api/apps/v1alpha1/nemo_common_types.go

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
type Mongodb struct {
20-
Endpoint string `json:"endpoint"`
21-
}
22-
2319
type ArgoWorkFlows struct {
2420
Endpoint string `json:"endpoint"`
2521
ServiceAccount string `json:"serviceAccount"`
@@ -32,3 +28,51 @@ type Milvus struct {
3228
type DataStore struct {
3329
Endpoint string `json:"endpoint"`
3430
}
31+
32+
type DatabaseConfig struct {
33+
// Host is the hostname of the database.
34+
// Required, must not be empty.
35+
//
36+
// +kubebuilder:validation:Required
37+
// +kubebuilder:validation:MinLength=1
38+
Host string `json:"host,omitempty"`
39+
// Port is the port where the database is reachable at.
40+
// If specified, this must be a valid port number, 0 < databasePort < 65536.
41+
// Defaults to 5432.
42+
//
43+
// +kubebuilder:validation:Minimum=1
44+
// +kubebuilder:validation:Maximum=65535
45+
// +kubebuilder:default:=5432
46+
Port int32 `json:"port,omitempty"`
47+
// DatabaseName is the database name for a NEMO Service.
48+
// Required, must not be empty.
49+
//
50+
// +kubebuilder:validation:Required
51+
// +kubebuilder:validation:MinLength=1
52+
DatabaseName string `json:"databaseName,omitempty"`
53+
// DatabaseCredentials stores the configuration to retrieve the database credentials.
54+
// Required, must not be nil.
55+
//
56+
// +kubebuilder:validation:Required
57+
Credentials *DatabaseCredentials `json:"credentials,omitempty"`
58+
}
59+
60+
type DatabaseCredentials struct {
61+
// User is the non-root username for a NEMO Service in the database.
62+
// Required, must not be empty.
63+
//
64+
// +kubebuilder:validation:Required
65+
// +kubebuilder:validation:MinLength=1
66+
User string `json:"user,omitempty"`
67+
// SecretName is the name of the secret which has the database credentials for a NEMO service user.
68+
// Required, must not be empty.
69+
//
70+
// +kubebuilder:validation:Required
71+
// +kubebuilder:validation:MinLength=1
72+
SecretName string `json:"secretName,omitempty"`
73+
// PasswordKey is the name of the key in the `CredentialsSecret` secret for the database credentials.
74+
// Defaults to "password".
75+
//
76+
// +kubebuilder:default:="password"
77+
PasswordKey string `json:"passwordKey,omitempty"`
78+
}

api/apps/v1alpha1/nemo_entitystore_types.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -85,54 +85,6 @@ type NemoEntitystoreSpec struct {
8585
DatabaseConfig *DatabaseConfig `json:"databaseConfig,omitempty"`
8686
}
8787

88-
type DatabaseConfig struct {
89-
// Host is the hostname of the database.
90-
// Required, must not be empty.
91-
//
92-
// +kubebuilder:validation:Required
93-
// +kubebuilder:validation:MinLength=1
94-
Host string `json:"host,omitempty"`
95-
// Port is the port where the database is reachable at.
96-
// If specified, this must be a valid port number, 0 < databasePort < 65536.
97-
// Defaults to 5432.
98-
//
99-
// +kubebuilder:validation:Minimum=1
100-
// +kubebuilder:validation:Maximum=65535
101-
// +kubebuilder:default:=5432
102-
Port int32 `json:"port,omitempty"`
103-
// DatabaseName is the database name for NEMO EntityStore.
104-
// Required, must not be empty.
105-
//
106-
// +kubebuilder:validation:Required
107-
// +kubebuilder:validation:MinLength=1
108-
DatabaseName string `json:"databaseName,omitempty"`
109-
// DatabaseCredentials stores the configuration to retrieve the database credentials.
110-
// Required, must not be nil.
111-
//
112-
// +kubebuilder:validation:Required
113-
Credentials *DatabaseCredentials `json:"credentials,omitempty"`
114-
}
115-
116-
type DatabaseCredentials struct {
117-
// User is the non-root username for NEMO EntityStore in the database.
118-
// Required, must not be empty.
119-
//
120-
// +kubebuilder:validation:Required
121-
// +kubebuilder:validation:MinLength=1
122-
User string `json:"user,omitempty"`
123-
// SecretName is the name of the secret which has the database credentials for the NEMO entitystore user.
124-
// Required, must not be empty.
125-
//
126-
// +kubebuilder:validation:Required
127-
// +kubebuilder:validation:MinLength=1
128-
SecretName string `json:"secretName,omitempty"`
129-
// PasswordKey is the name of the key in the `CredentialsSecret` secret for the database credentials.
130-
// Defaults to "password".
131-
//
132-
// +kubebuilder:default:="password"
133-
PasswordKey string `json:"passwordKey,omitempty"`
134-
}
135-
13688
// NemoEntitystoreStatus defines the observed state of NemoEntitystore
13789
type NemoEntitystoreStatus struct {
13890
Conditions []metav1.Condition `json:"conditions,omitempty"`

api/apps/v1alpha1/nemo_evaluator_types.go

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ type NemoEvaluatorSpec struct {
7474
GroupID *int64 `json:"groupID,omitempty"`
7575
RuntimeClass string `json:"runtimeClass,omitempty"`
7676

77-
Mongodb *Mongodb `json:"mongodb,omitempty"`
78-
ArgoWorkFlows *ArgoWorkFlows `json:"argoWorkFlows,omitempty"`
79-
Milvus *Milvus `json:"milvus,omitempty"`
80-
DataStore *DataStore `json:"dataStore,omitempty"`
77+
// DatabaseConfig stores the database configuration for NEMO entitystore.
78+
// Required, must not be nil.
79+
//
80+
// +kubebuilder:validation:Required
81+
DatabaseConfig *DatabaseConfig `json:"databaseConfig,omitempty"`
82+
ArgoWorkFlows *ArgoWorkFlows `json:"argoWorkFlows,omitempty"`
83+
Milvus *Milvus `json:"milvus,omitempty"`
84+
DataStore *DataStore `json:"dataStore,omitempty"`
8185
}
8286

8387
// NemoEvaluatorStatus defines the observed state of NemoEvaluator
@@ -156,12 +160,19 @@ func (n *NemoEvaluator) GetStandardEnv() []corev1.EnvVar {
156160
Value: "7331",
157161
},
158162
{
159-
Name: "DATABASE_URI",
160-
Value: n.Spec.Mongodb.Endpoint,
163+
Name: "POSTGRES_DB_PASSWORD",
164+
ValueFrom: &corev1.EnvVarSource{
165+
SecretKeyRef: &corev1.SecretKeySelector{
166+
Key: n.Spec.DatabaseConfig.Credentials.PasswordKey,
167+
LocalObjectReference: corev1.LocalObjectReference{
168+
Name: n.Spec.DatabaseConfig.Credentials.SecretName,
169+
},
170+
},
171+
},
161172
},
162173
{
163-
Name: "DATABASE_NAME",
164-
Value: "evaluations",
174+
Name: "POSTGRES_URI",
175+
Value: fmt.Sprintf("postgresql://%s:$(POSTGRES_DB_PASSWORD)@%s:%d/%s", n.Spec.DatabaseConfig.Credentials.User, n.Spec.DatabaseConfig.Host, n.Spec.DatabaseConfig.Port, n.Spec.DatabaseConfig.DatabaseName),
165176
},
166177
{
167178
Name: "ARGO_HOST",
@@ -179,19 +190,6 @@ func (n *NemoEvaluator) GetStandardEnv() []corev1.EnvVar {
179190
Name: "DATA_STORE_HOST",
180191
Value: n.Spec.DataStore.Endpoint,
181192
},
182-
{
183-
Name: "DATABASE_USERNAME",
184-
Value: "root",
185-
},
186-
{
187-
Name: "DATABASE_PASSWORD",
188-
ValueFrom: &corev1.EnvVarSource{
189-
SecretKeyRef: &corev1.SecretKeySelector{
190-
Key: "mongodb-root-password",
191-
LocalObjectReference: corev1.LocalObjectReference{Name: "myrelease-mongodb"},
192-
},
193-
},
194-
},
195193
{
196194
Name: "EVAL_CONTAINER",
197195
Value: n.GetImage(),

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/apps.nvidia.com_nemoentitystores.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ spec:
8181
type: string
8282
secretName:
8383
description: |-
84-
SecretName is the name of the secret which has the database credentials for the NEMO entitystore user.
84+
SecretName is the name of the secret which has the database credentials for a NEMO service user.
8585
Required, must not be empty.
8686
minLength: 1
8787
type: string
8888
user:
8989
description: |-
90-
User is the non-root username for NEMO EntityStore in the database.
90+
User is the non-root username for a NEMO Service in the database.
9191
Required, must not be empty.
9292
minLength: 1
9393
type: string
@@ -97,7 +97,7 @@ spec:
9797
type: object
9898
databaseName:
9999
description: |-
100-
DatabaseName is the database name for NEMO EntityStore.
100+
DatabaseName is the database name for a NEMO Service.
101101
Required, must not be empty.
102102
minLength: 1
103103
type: string

bundle/manifests/apps.nvidia.com_nemoevaluators.yaml

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,65 @@ spec:
7676
required:
7777
- endpoint
7878
type: object
79+
databaseConfig:
80+
description: |-
81+
DatabaseConfig stores the database configuration for NEMO entitystore.
82+
Required, must not be nil.
83+
properties:
84+
credentials:
85+
description: |-
86+
DatabaseCredentials stores the configuration to retrieve the database credentials.
87+
Required, must not be nil.
88+
properties:
89+
passwordKey:
90+
default: password
91+
description: |-
92+
PasswordKey is the name of the key in the `CredentialsSecret` secret for the database credentials.
93+
Defaults to "password".
94+
type: string
95+
secretName:
96+
description: |-
97+
SecretName is the name of the secret which has the database credentials for a NEMO service user.
98+
Required, must not be empty.
99+
minLength: 1
100+
type: string
101+
user:
102+
description: |-
103+
User is the non-root username for a NEMO Service in the database.
104+
Required, must not be empty.
105+
minLength: 1
106+
type: string
107+
required:
108+
- secretName
109+
- user
110+
type: object
111+
databaseName:
112+
description: |-
113+
DatabaseName is the database name for a NEMO Service.
114+
Required, must not be empty.
115+
minLength: 1
116+
type: string
117+
host:
118+
description: |-
119+
Host is the hostname of the database.
120+
Required, must not be empty.
121+
minLength: 1
122+
type: string
123+
port:
124+
default: 5432
125+
description: |-
126+
Port is the port where the database is reachable at.
127+
If specified, this must be a valid port number, 0 < databasePort < 65536.
128+
Defaults to 5432.
129+
format: int32
130+
maximum: 65535
131+
minimum: 1
132+
type: integer
133+
required:
134+
- credentials
135+
- databaseName
136+
- host
137+
type: object
79138
env:
80139
items:
81140
description: EnvVar represents an environment variable present in
@@ -725,13 +784,6 @@ spec:
725784
required:
726785
- endpoint
727786
type: object
728-
mongodb:
729-
properties:
730-
endpoint:
731-
type: string
732-
required:
733-
- endpoint
734-
type: object
735787
nodeSelector:
736788
additionalProperties:
737789
type: string
@@ -2126,6 +2178,8 @@ spec:
21262178
userID:
21272179
format: int64
21282180
type: integer
2181+
required:
2182+
- databaseConfig
21292183
type: object
21302184
status:
21312185
description: NemoEvaluatorStatus defines the observed state of NemoEvaluator

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ spec:
8181
type: string
8282
secretName:
8383
description: |-
84-
SecretName is the name of the secret which has the database credentials for the NEMO entitystore user.
84+
SecretName is the name of the secret which has the database credentials for a NEMO service user.
8585
Required, must not be empty.
8686
minLength: 1
8787
type: string
8888
user:
8989
description: |-
90-
User is the non-root username for NEMO EntityStore in the database.
90+
User is the non-root username for a NEMO Service in the database.
9191
Required, must not be empty.
9292
minLength: 1
9393
type: string
@@ -97,7 +97,7 @@ spec:
9797
type: object
9898
databaseName:
9999
description: |-
100-
DatabaseName is the database name for NEMO EntityStore.
100+
DatabaseName is the database name for a NEMO Service.
101101
Required, must not be empty.
102102
minLength: 1
103103
type: string

0 commit comments

Comments
 (0)