@@ -20,6 +20,7 @@ import (
20
20
"fmt"
21
21
"maps"
22
22
"os"
23
+ "strconv"
23
24
24
25
rendertypes "github.com/NVIDIA/k8s-nim-operator/internal/render/types"
25
26
utils "github.com/NVIDIA/k8s-nim-operator/internal/utils"
@@ -79,7 +80,19 @@ type NemoDatastoreSpec struct {
79
80
GroupID *int64 `json:"groupID,omitempty"`
80
81
RuntimeClass string `json:"runtimeClass,omitempty"`
81
82
82
- DataStoreParams NemoDatastoreParams `json:"dataStoreParams"`
83
+ ObjectStore ObjectStore `json:"objectStore"` // e.g. minio
84
+ ExternalDatabase ExternalDatabase `json:"externalDatabase"` // e.g. postgres
85
+
86
+ Secrets Secrets `json:"secrets"`
87
+ PVC *PersistentVolumeClaim `json:"pvc,omitempty"`
88
+ }
89
+
90
+ type Secrets struct {
91
+ GiteaAdminSecret string `json:"giteaAdminSecret"`
92
+ LfsJwtSecret string `json:"lfsJwtSecret"`
93
+ DataStoreInitSecret string `json:"datastoreInitSecret"`
94
+ DataStoreConfigSecret string `json:"datastoreConfigSecret"` // config_environment.sh
95
+ DataStoreInlineConfigSecret string `json:"datastoreInlineConfigSecret"`
83
96
}
84
97
85
98
// NemoDatastoreStatus defines the observed state of NemoDatastore
@@ -89,21 +102,26 @@ type NemoDatastoreStatus struct {
89
102
State string `json:"state,omitempty"`
90
103
}
91
104
92
- type NemoDatastoreParams struct {
93
- DBSecret string `json:"dbSecret"`
94
- GiteaAdminSecret string `json:"giteaAdminSecret"`
95
-
96
- ObjectStoreSecret string `json:"objStoreSecret"`
97
- DataStoreSettingsSecret string `json:"datastoreSettingsSecret"`
98
- LfsJwtSecret string `json:"lfsJwtSecret"`
105
+ type ObjectStore struct { // e.g. Minio, s3
106
+ ObjectStoreSecret string `json:"objectStoreSecret"`
107
+ ObjectStoreAccessKey string `json:"objectStoreSecretAccessKey"`
108
+ ObjectStoreSecretAccessSecret string `json:"objectStoreSecretAccessSecret"`
99
109
100
- DataStoreInitSecret string `json:"datastoreInitSecret"`
101
- DataStoreConfigSecret string `json:"datastoreConfigSecret"`
102
- DataStoreInlineConfigSecret string `json:"datastoreInlineConfigSecret"`
103
-
104
- SshEnabled bool `json:"sshEnabled"`
110
+ ServeDirect bool `json:"serveDirect"`
111
+ Endpoint string `json:"endpoint"`
112
+ BucketName string `json:"bucketName"`
113
+ Region string `json:"region"`
114
+ SSL bool `json:"ssl"`
115
+ }
105
116
106
- PVC *PersistentVolumeClaim `json:"pvc,omitempty"`
117
+ type ExternalDatabase struct {
118
+ SSLMode string `json:"sslMode"`
119
+ Host string `json:"host"`
120
+ Port int `json:"port"`
121
+ User string `json:"user"`
122
+ Database string `json:"database"`
123
+ DatabaseSecret string `json:"databaseSecret"`
124
+ DatabaseSecretKey string `json:"databaseSecretKey"`
107
125
}
108
126
109
127
// +genclient
@@ -134,9 +152,8 @@ type NemoDatastoreList struct {
134
152
// Prefers pvc.Name if explicitly set by the user in the NemoDatastore instance
135
153
func (n *NemoDatastore) GetPVCName() string {
136
154
pvcName := fmt.Sprintf("%s-pvc", n.GetName())
137
- dsParam := n.Spec.DataStoreParams
138
- if dsParam.PVC != nil && dsParam.PVC.Name != "" {
139
- pvcName = dsParam.PVC.Name
155
+ if n.Spec.PVC != nil && n.Spec.PVC.Name != "" {
156
+ pvcName = n.Spec.PVC.Name
140
157
}
141
158
return pvcName
142
159
}
@@ -200,9 +217,9 @@ func (n *NemoDatastore) GetStandardEnv() []corev1.EnvVar {
200
217
Name: "GITEA__LFS__MINIO_ACCESS_KEY_ID",
201
218
ValueFrom: &corev1.EnvVarSource{
202
219
SecretKeyRef: &corev1.SecretKeySelector{
203
- Key: "objectStoreKey" ,
220
+ Key: n.Spec.ObjectStore.ObjectStoreAccessKey ,
204
221
LocalObjectReference: corev1.LocalObjectReference{
205
- Name: n.Spec.DataStoreParams .ObjectStoreSecret,
222
+ Name: n.Spec.ObjectStore .ObjectStoreSecret,
206
223
},
207
224
},
208
225
},
@@ -211,9 +228,9 @@ func (n *NemoDatastore) GetStandardEnv() []corev1.EnvVar {
211
228
Name: "GITEA__LFS__MINIO_SECRET_ACCESS_KEY",
212
229
ValueFrom: &corev1.EnvVarSource{
213
230
SecretKeyRef: &corev1.SecretKeySelector{
214
- Key: "objectStoreSecret" ,
231
+ Key: n.Spec.ObjectStore.ObjectStoreSecretAccessSecret ,
215
232
LocalObjectReference: corev1.LocalObjectReference{
216
- Name: n.Spec.DataStoreParams .ObjectStoreSecret,
233
+ Name: n.Spec.ObjectStore .ObjectStoreSecret,
217
234
},
218
235
},
219
236
},
@@ -224,7 +241,7 @@ func (n *NemoDatastore) GetStandardEnv() []corev1.EnvVar {
224
241
SecretKeyRef: &corev1.SecretKeySelector{
225
242
Key: "jwtSecret",
226
243
LocalObjectReference: corev1.LocalObjectReference{
227
- Name: n.Spec.DataStoreParams .LfsJwtSecret,
244
+ Name: n.Spec.Secrets .LfsJwtSecret,
228
245
},
229
246
},
230
247
},
@@ -233,9 +250,9 @@ func (n *NemoDatastore) GetStandardEnv() []corev1.EnvVar {
233
250
Name: "GITEA__DATABASE__PASSWD",
234
251
ValueFrom: &corev1.EnvVarSource{
235
252
SecretKeyRef: &corev1.SecretKeySelector{
236
- Key: "postgresPassword" ,
253
+ Key: n.Spec.ExternalDatabase.DatabaseSecretKey ,
237
254
LocalObjectReference: corev1.LocalObjectReference{
238
- Name: n.Spec.DataStoreParams.DBSecret ,
255
+ Name: n.Spec.ExternalDatabase.DatabaseSecret ,
239
256
},
240
257
},
241
258
},
@@ -245,6 +262,9 @@ func (n *NemoDatastore) GetStandardEnv() []corev1.EnvVar {
245
262
}
246
263
247
264
func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
265
+ objStoreSetting := n.Spec.ObjectStore
266
+ dbSetting := n.Spec.ExternalDatabase
267
+
248
268
envVars := []corev1.EnvVar{
249
269
{
250
270
Name: "GITEA_APP_INI",
@@ -274,9 +294,9 @@ func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
274
294
Name: "GITEA__LFS__MINIO_ACCESS_KEY_ID",
275
295
ValueFrom: &corev1.EnvVarSource{
276
296
SecretKeyRef: &corev1.SecretKeySelector{
277
- Key: "objectStoreKey" ,
297
+ Key: objStoreSetting.ObjectStoreAccessKey ,
278
298
LocalObjectReference: corev1.LocalObjectReference{
279
- Name: n.Spec.DataStoreParams .ObjectStoreSecret,
299
+ Name: objStoreSetting .ObjectStoreSecret,
280
300
},
281
301
},
282
302
},
@@ -285,9 +305,9 @@ func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
285
305
Name: "GITEA__LFS__MINIO_SECRET_ACCESS_KEY",
286
306
ValueFrom: &corev1.EnvVarSource{
287
307
SecretKeyRef: &corev1.SecretKeySelector{
288
- Key: "objectStoreSecret" ,
308
+ Key: objStoreSetting.ObjectStoreSecretAccessSecret ,
289
309
LocalObjectReference: corev1.LocalObjectReference{
290
- Name: n.Spec.DataStoreParams .ObjectStoreSecret,
310
+ Name: objStoreSetting .ObjectStoreSecret,
291
311
},
292
312
},
293
313
},
@@ -298,7 +318,7 @@ func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
298
318
SecretKeyRef: &corev1.SecretKeySelector{
299
319
Key: "jwtSecret",
300
320
LocalObjectReference: corev1.LocalObjectReference{
301
- Name: n.Spec.DataStoreParams .LfsJwtSecret,
321
+ Name: n.Spec.Secrets .LfsJwtSecret,
302
322
},
303
323
},
304
324
},
@@ -307,9 +327,9 @@ func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
307
327
Name: "GITEA__DATABASE__PASSWD",
308
328
ValueFrom: &corev1.EnvVarSource{
309
329
SecretKeyRef: &corev1.SecretKeySelector{
310
- Key: "postgresPassword" ,
330
+ Key: dbSetting.DatabaseSecretKey ,
311
331
LocalObjectReference: corev1.LocalObjectReference{
312
- Name: n.Spec.DataStoreParams.DBSecret ,
332
+ Name: dbSetting.DatabaseSecret ,
313
333
},
314
334
},
315
335
},
@@ -320,7 +340,7 @@ func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
320
340
SecretKeyRef: &corev1.SecretKeySelector{
321
341
Key: "GITEA_ADMIN_USERNAME",
322
342
LocalObjectReference: corev1.LocalObjectReference{
323
- Name: n.Spec.DataStoreParams .GiteaAdminSecret,
343
+ Name: n.Spec.Secrets .GiteaAdminSecret,
324
344
},
325
345
},
326
346
},
@@ -331,11 +351,55 @@ func (n *NemoDatastore) GetInitContainerEnv() []corev1.EnvVar {
331
351
SecretKeyRef: &corev1.SecretKeySelector{
332
352
Key: "GITEA_ADMIN_PASSWORD",
333
353
LocalObjectReference: corev1.LocalObjectReference{
334
- Name: n.Spec.DataStoreParams .GiteaAdminSecret,
354
+ Name: n.Spec.Secrets .GiteaAdminSecret,
335
355
},
336
356
},
337
357
},
338
358
},
359
+ {
360
+ Name: "GITEA__LFS__SERVE_DIRECT",
361
+ Value: strconv.FormatBool(objStoreSetting.ServeDirect),
362
+ },
363
+ {
364
+ Name: "GITEA__LFS__STORAGE_TYPE",
365
+ Value: "minio",
366
+ },
367
+ {
368
+ Name: "GITEA__LFS__MINIO_ENDPOINT",
369
+ Value: objStoreSetting.Endpoint,
370
+ },
371
+ {
372
+ Name: "GITEA__LFS__MINIO_BUCKET",
373
+ Value: objStoreSetting.BucketName,
374
+ },
375
+ {
376
+ Name: "GITEA__LFS__MINIO_LOCATION",
377
+ Value: objStoreSetting.Region,
378
+ },
379
+ {
380
+ Name: "GITEA__LFS__MINIO_LOCATION",
381
+ Value: objStoreSetting.Region,
382
+ },
383
+ {
384
+ Name: "GITEA__LFS__MINIO_USE_SSL",
385
+ Value: strconv.FormatBool(objStoreSetting.SSL),
386
+ },
387
+ {
388
+ Name: "GITEA__DATABASE__SSL_MODE",
389
+ Value: dbSetting.SSLMode,
390
+ },
391
+ {
392
+ Name: "GITEA__DATABASE__NAME",
393
+ Value: dbSetting.Database,
394
+ },
395
+ {
396
+ Name: "GITEA__DATABASE__HOST",
397
+ Value: fmt.Sprintf("%s:%d", dbSetting.Host, dbSetting.Port),
398
+ },
399
+ {
400
+ Name: "GITEA__DATABASE__USER",
401
+ Value: dbSetting.User,
402
+ },
339
403
}
340
404
return envVars
341
405
}
@@ -369,7 +433,7 @@ func (n *NemoDatastore) GetVolumes() []corev1.Volume {
369
433
Name: "init",
370
434
VolumeSource: corev1.VolumeSource{
371
435
Secret: &corev1.SecretVolumeSource{
372
- SecretName: n.Spec.DataStoreParams .DataStoreInitSecret,
436
+ SecretName: n.Spec.Secrets .DataStoreInitSecret,
373
437
DefaultMode: &initMode,
374
438
},
375
439
},
@@ -378,7 +442,7 @@ func (n *NemoDatastore) GetVolumes() []corev1.Volume {
378
442
Name: "config",
379
443
VolumeSource: corev1.VolumeSource{
380
444
Secret: &corev1.SecretVolumeSource{
381
- SecretName: n.Spec.DataStoreParams .DataStoreConfigSecret,
445
+ SecretName: n.Spec.Secrets .DataStoreConfigSecret,
382
446
DefaultMode: &initMode,
383
447
},
384
448
},
@@ -387,7 +451,7 @@ func (n *NemoDatastore) GetVolumes() []corev1.Volume {
387
451
Name: "inline-config-sources",
388
452
VolumeSource: corev1.VolumeSource{
389
453
Secret: &corev1.SecretVolumeSource{
390
- SecretName: n.Spec.DataStoreParams .DataStoreInlineConfigSecret,
454
+ SecretName: n.Spec.Secrets .DataStoreInlineConfigSecret,
391
455
DefaultMode: &configMode,
392
456
},
393
457
},
@@ -400,7 +464,7 @@ func (n *NemoDatastore) GetVolumes() []corev1.Volume {
400
464
},
401
465
}
402
466
403
- if n.Spec.DataStoreParams. PVC != nil {
467
+ if n.Spec.PVC != nil {
404
468
volumes = append(volumes, corev1.Volume{
405
469
Name: "data",
406
470
VolumeSource: corev1.VolumeSource{
@@ -421,27 +485,14 @@ func (n *NemoDatastore) GetVolumes() []corev1.Volume {
421
485
}
422
486
423
487
func (n *NemoDatastore) ShouldCreatePersistentStorage() bool {
424
- return n.Spec.DataStoreParams. PVC != nil && n.Spec.DataStoreParams. PVC.Create != nil && *n.Spec.DataStoreParams .PVC.Create
488
+ return n.Spec.PVC != nil && n.Spec.PVC.Create != nil && *n.Spec.PVC.Create
425
489
}
426
490
427
491
// GetStandardAnnotations returns default annotations to apply to the NemoDatastore instance
428
492
func (n *NemoDatastore) GetEnvFrom() []corev1.EnvFromSource {
429
493
return []corev1.EnvFromSource{}
430
494
}
431
495
432
- // GetStandardAnnotations returns default annotations to apply to the NemoDatastore instance
433
- func (n *NemoDatastore) GetInitAppIniEnvFrom() []corev1.EnvFromSource {
434
- return []corev1.EnvFromSource{
435
- {
436
- SecretRef: &corev1.SecretEnvSource{
437
- LocalObjectReference: corev1.LocalObjectReference{
438
- Name: n.Spec.DataStoreParams.DataStoreSettingsSecret,
439
- },
440
- },
441
- },
442
- }
443
- }
444
-
445
496
// GetStandardAnnotations returns default annotations to apply to the NemoDatastore instance
446
497
func (n *NemoDatastore) GetStandardAnnotations() map[string]string {
447
498
standardAnnotations := map[string]string{
@@ -633,8 +684,8 @@ func (n *NemoDatastore) GetVolumeMounts() []corev1.VolumeMount {
633
684
Name: "data",
634
685
}
635
686
636
- if n.Spec.DataStoreParams. PVC != nil {
637
- dataMount.SubPath = n.Spec.DataStoreParams. PVC.SubPath
687
+ if n.Spec.PVC != nil {
688
+ dataMount.SubPath = n.Spec.PVC.SubPath
638
689
}
639
690
mounts = append(mounts, dataMount)
640
691
return mounts
@@ -664,8 +715,8 @@ func (n *NemoDatastore) GetVolumeMountsInitContainer() []corev1.VolumeMount {
664
715
Name: "data",
665
716
}
666
717
667
- if n.Spec.DataStoreParams. PVC != nil {
668
- dataMount.SubPath = n.Spec.DataStoreParams. PVC.SubPath
718
+ if n.Spec.PVC != nil {
719
+ dataMount.SubPath = n.Spec.PVC.SubPath
669
720
}
670
721
mounts = append(mounts, dataMount)
671
722
return mounts
@@ -682,7 +733,6 @@ func (n *NemoDatastore) GetInitContainers() []corev1.Container {
682
733
},
683
734
VolumeMounts: n.GetVolumeMountsInitContainer(),
684
735
Env: n.GetInitContainerEnv(),
685
- EnvFrom: n.GetInitAppIniEnvFrom(),
686
736
},
687
737
{
688
738
Name: "init-app-ini",
@@ -693,7 +743,6 @@ func (n *NemoDatastore) GetInitContainers() []corev1.Container {
693
743
},
694
744
VolumeMounts: n.GetVolumeMountsInitContainer(),
695
745
Env: n.GetInitContainerEnv(),
696
- EnvFrom: n.GetInitAppIniEnvFrom(),
697
746
},
698
747
{
699
748
Name: "configure-datastore",
@@ -707,7 +756,6 @@ func (n *NemoDatastore) GetInitContainers() []corev1.Container {
707
756
},
708
757
VolumeMounts: n.GetVolumeMountsInitContainer(),
709
758
Env: n.GetInitContainerEnv(),
710
- EnvFrom: n.GetInitAppIniEnvFrom(),
711
759
SecurityContext: &corev1.SecurityContext{
712
760
RunAsUser: n.GetUserID(),
713
761
},
0 commit comments