From 48533a77c2e2e65754c40830cd1f73f3cb63e92e Mon Sep 17 00:00:00 2001 From: Achyut Madhusudan Date: Sat, 20 Apr 2024 03:38:47 +0530 Subject: [PATCH] Customizable kfp-launcher with a config map Signed-off-by: Achyut Madhusudan --- api/v1alpha1/dspipeline_types.go | 4 ++++ ...ub.io_datasciencepipelinesapplications.yaml | 5 +++++ .../default/kfp_launcher_config.yaml.tmpl | 17 +++++++++++------ .../v2/dspa-all-fields/dspa_all_fields.yaml | 1 + controllers/dspipeline_params.go | 18 ++++++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/dspipeline_types.go b/api/v1alpha1/dspipeline_types.go index 75652665d..7109c06e1 100644 --- a/api/v1alpha1/dspipeline_types.go +++ b/api/v1alpha1/dspipeline_types.go @@ -80,6 +80,10 @@ type APIServer struct { // for the api server to use instead. CustomServerConfig *ScriptConfigMap `json:"customServerConfigMap,omitempty"` + // CustomKfpLauncherConfig is a custom config file that you can provide + // for the api server to use instead of the one provided with DSPO. + CustomKfpLauncherConfig string `json:"customKfpLauncherConfigMap,omitempty"` + // Default: true // Deprecated: DSP V1 only, will be removed in the future. // +kubebuilder:default:=true diff --git a/config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml b/config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml index 749ff2edf..1dbd443f5 100644 --- a/config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml +++ b/config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml @@ -106,6 +106,11 @@ spec: description: 'Default: true Deprecated: DSP V1 only, will be removed in the future.' type: boolean + customKfpLauncherConfigMap: + description: CustomKfpLauncherConfig is a custom config file that + you can provide for the api server to use instead of the one + provided with DSPO. + type: string customServerConfigMap: description: CustomServerConfig is a custom config file that you can provide for the api server to use instead. diff --git a/config/internal/apiserver/default/kfp_launcher_config.yaml.tmpl b/config/internal/apiserver/default/kfp_launcher_config.yaml.tmpl index 1d497b584..0aa2b481c 100644 --- a/config/internal/apiserver/default/kfp_launcher_config.yaml.tmpl +++ b/config/internal/apiserver/default/kfp_launcher_config.yaml.tmpl @@ -1,5 +1,9 @@ apiVersion: v1 data: + {{ if .APIServer.CustomKfpLauncherConfig }} + providers: | + {{.CustomKfpLauncherConfigMap.Data}} + {{ else }} {{ if .ObjectStorageConnection.BasePath }} defaultPipelineRoot: s3://{{.ObjectStorageConnection.Bucket}}/{{.ObjectStorageConnection.BasePath}} {{ else }} @@ -12,11 +16,12 @@ data: defaultProviderSecretRef: secretName: {{.ObjectStorageConnection.CredentialsSecret.SecretName}} accessKeyKey: {{.ObjectStorageConnection.CredentialsSecret.AccessKey}} - secretKeyKey: {{.ObjectStorageConnection.CredentialsSecret.SecretKey}} + secretKeyKey: {{.ObjectStorageConnection.CredentialsSecret.SecretKey}}` + {{ end }} kind: ConfigMap metadata: - name: kfp-launcher - namespace: {{.Namespace}} - labels: - app: ds-pipeline-{{.Name}} - component: data-science-pipelines + name: kfp-launcher + namespace: {{.Namespace}} + labels: + app: ds-pipeline-{{.Name}} + component: data-science-pipelines diff --git a/config/samples/v2/dspa-all-fields/dspa_all_fields.yaml b/config/samples/v2/dspa-all-fields/dspa_all_fields.yaml index 31815994b..c98293c0f 100644 --- a/config/samples/v2/dspa-all-fields/dspa_all_fields.yaml +++ b/config/samples/v2/dspa-all-fields/dspa_all_fields.yaml @@ -11,6 +11,7 @@ metadata: spec: dspVersion: v2 apiServer: + customKfpLauncherConfigMap: configmapname deploy: true image: quay.io/opendatahub/ds-pipelines-api-server:latest argoLauncherImage: quay.io/org/kfp-launcher:latest diff --git a/controllers/dspipeline_params.go b/controllers/dspipeline_params.go index e95c863a2..c672bd874 100644 --- a/controllers/dspipeline_params.go +++ b/controllers/dspipeline_params.go @@ -68,6 +68,7 @@ type DSPAParams struct { WorkflowController *dspa.WorkflowController DBConnection ObjectStorageConnection + CustomKfpLauncherConfigMap // TLS // The CA bundle path used by API server @@ -88,6 +89,10 @@ type DSPAParams struct { DSPONamespace string } +type CustomKfpLauncherConfigMap struct { + Data string +} + type DBConnection struct { Host string Port string @@ -630,6 +635,19 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip } } + if cfg := p.APIServer.CustomKfpLauncherConfig; cfg != "" { + if cm, err := util.GetConfigMap(ctx, cfg, p.Namespace, client); err != nil { + // If the custom kfp-launcher configmap is not available, that is OK + if !apierrs.IsNotFound(err) { + log.Error(err, fmt.Sprintf("Encountered error when attempting to fetch ConfigMap: [%s], Error: %v", cfg, err)) + return err + } + } else { + // Consume all the required information. + dataValues := util.GetConfigMapValues(cm) + p.CustomKfpLauncherConfigMap.Data = strings.Join(dataValues, " ") + } + } // Track whether the "ca-bundle.crt" configmap key from odh-trusted-ca bundle // was found, this will be used to decide whether we need to account for this // ourselves later or not.