Skip to content

Commit

Permalink
Create DevTools in DSPA CR, Add Database/Storage Secret Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
gmfrasca committed May 23, 2023
1 parent e5d0fd1 commit ecc93f8
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 2 deletions.
12 changes: 12 additions & 0 deletions api/v1alpha1/dspipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type DSPASpec struct {
*MlPipelineUI `json:"mlpipelineUI"`
// +kubebuilder:validation:Required
*ObjectStorage `json:"objectStorage"`
// DevTools enables non-production tools and utilities for Data Science Pipelines Operator developers
// +kubebuilder:validation:Optional
*DevTools `json:"devtools"`
}

type APIServer struct {
Expand Down Expand Up @@ -164,6 +167,15 @@ type Minio struct {
Image string `json:"image"`
}

type DevTools struct {
// +kubebuilder:default:=false
// +kubebuilder:validation:Optional
EnableDatabaseSecret bool `json:"enableDatabaseSecret"`
// +kubebuilder:default:=false
// +kubebuilder:validation:Optional
EnableStorageSecret bool `json:"enableStorageSecret"`
}

// ResourceRequirements structures compute resource requirements.
// Replaces ResourceRequirements from corev1 which also includes optional storage field.
// We handle storage field separately, and should not include it as a subfield for Resources.
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ spec:
type: string
type: object
type: object
devtools:
description: DevTools enables non-production tools and utilities for
Data Science Pipelines Operator developers
properties:
enableDatabaseSecret:
default: false
type: boolean
enableStorageSecret:
default: false
type: boolean
type: object
mlpipelineUI:
properties:
configMap:
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion controllers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var dbTemplates = []string{
"mariadb/pvc.yaml.tmpl",
"mariadb/sa.yaml.tmpl",
"mariadb/service.yaml.tmpl",
"mariadb/secret.yaml.tmpl",
}

func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha1.DataSciencePipelinesApplication,
Expand Down
53 changes: 53 additions & 0 deletions controllers/developer_tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers

import (
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
)

const dbSecret = "devtools/database.secret.yaml.tmpl"
const storageSecret = "devtools/storage.secret.yaml.tmpl"

func (r *DSPAReconciler) ReconcileDevtools(dsp *dspav1alpha1.DataSciencePipelinesApplication, params *DSPAParams) error {

log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)

if dsp.Spec.DevTools != nil {
log.Info("Applying DevTool Resources")

dbSecretEnabled := dsp.Spec.DevTools.EnableDatabaseSecret
storageSecretEnabled := dsp.Spec.DevTools.EnableStorageSecret

if dbSecretEnabled {
log.Info("Database secret creation requested")
err := r.Apply(dsp, params, dbSecret)
if err != nil {
return err
}
}

if storageSecretEnabled {
log.Info("Object Storage secret creation requested")
err := r.Apply(dsp, params, storageSecret)
if err != nil {
return err
}
}
log.Info("Finished applying DevTool Resources")
}
return nil
}
5 changes: 5 additions & 0 deletions controllers/dspipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
return ctrl.Result{}, err
}

err = r.ReconcileDevtools(dspa, params)
if err != nil {
return ctrl.Result{}, err
}

log.Info("Updating CR status")
// Refresh DSPA before updating
err = r.Get(ctx, req.NamespacedName, dspa)
Expand Down
2 changes: 2 additions & 0 deletions controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type DSPAParams struct {
MlPipelineUI *dspa.MlPipelineUI
MariaDB *dspa.MariaDB
Minio *dspa.Minio
DevTools *dspa.DevTools
DBConnection
ObjectStorageConnection
}
Expand Down Expand Up @@ -360,6 +361,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
p.MlPipelineUI = dsp.Spec.MlPipelineUI.DeepCopy()
p.MariaDB = dsp.Spec.MariaDB.DeepCopy()
p.Minio = dsp.Spec.Minio.DeepCopy()
p.DevTools = dsp.Spec.DevTools.DeepCopy()
p.OAuthProxy = config.GetStringConfigWithDefault(config.OAuthProxyImagePath, config.DefaultImageValue)

// TODO: If p.<component> is nil we should create defaults
Expand Down
1 change: 0 additions & 1 deletion controllers/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var storageTemplates = []string{
"minio/deployment.yaml.tmpl",
"minio/pvc.yaml.tmpl",
"minio/service.yaml.tmpl",
"minio/secret.yaml.tmpl",
}

// ReconcileStorage will set up Storage Connection.
Expand Down
3 changes: 3 additions & 0 deletions controllers/testdata/declarative/case_3/deploy/02_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ spec:
mlpipelineUI:
deploy: false
image: frontend:test3
devtools:
enableDatabaseSecret: true
enableStorageSecret: true

0 comments on commit ecc93f8

Please sign in to comment.