Skip to content

Commit

Permalink
add ability to customize kfp-launcher ConfigMap data contents
Browse files Browse the repository at this point in the history
Allow the user to fully replace the `data` contents of the kfp-launcher ConfigMap.
The `kfp-launcher` component requires a ConfigMap to exist in the namespace
where it runs (i.e. the namespace where pipelines run). This ConfigMap contains
object storage configuration, as well as pipeline root (object store root path
where artifacts will be uploaded) configuration. Currently this ConfigMap *must*
be named "kfp-launcher". We currently deploy a default copy of the kfp-launcher
ConfigMap via DSPO, but a user may want to provide their own ConfigMap configuration,
so that they can specify multiple object storage sources and paths.

Add a `CustomKfpLauncherConfigMap` parameter to DSPA.ApiServer. When specified,
the `data` contents of the `kfp-launcher` ConfigMap that DSPO writes will be fully
replaced with the `data` contents of the ConfigMap specified here.

Fixes: https://issues.redhat.com/browse/RHOAIENG-4528

Co-authored-by: Achyut Madhusudan <amadhusu@redhat.com>
  • Loading branch information
gregsheremeta and Achyut Madhusudan committed Aug 5, 2024
1 parent c03a6ab commit 167bb24
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/v1alpha1/dspipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ type APIServer struct {
// for the api server to use instead.
CustomServerConfig *ScriptConfigMap `json:"customServerConfigMap,omitempty"`

// When specified, the `data` contents of the `kfp-launcher` ConfigMap that DSPO writes
// will be fully replaced with the `data` contents of the ConfigMap specified here.
// This allows the user to fully replace the `data` contents of the kfp-launcher ConfigMap.
// The `kfp-launcher` component requires a ConfigMap to exist in the namespace
// where it runs (i.e. the namespace where pipelines run). This ConfigMap contains
// object storage configuration, as well as pipeline root (object store root path
// where artifacts will be uploaded) configuration. Currently this ConfigMap *must*
// be named "kfp-launcher". We currently deploy a default copy of the kfp-launcher
// ConfigMap via DSPO, but a user may want to provide their own ConfigMap configuration,
// so that they can specify multiple object storage sources and paths.
// +kubebuilder:validation:Optional
CustomKfpLauncherConfigMap string `json:"customKfpLauncherConfigMap,omitempty"`

// Default: true
// Deprecated: DSP V1 only, will be removed in the future.
// +kubebuilder:default:=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ spec:
description: 'Default: true Deprecated: DSP V1 only, will be removed
in the future.'
type: boolean
customKfpLauncherConfigMap:
description: "When specified, the `data` contents of the `kfp-launcher`
ConfigMap that DSPO writes will be fully replaced with the `data`
contents of the ConfigMap specified here. This allows the user
to fully replace the `data` contents of the kfp-launcher ConfigMap.
The `kfp-launcher` component requires a ConfigMap to exist in
the namespace where it runs (i.e. the\tnamespace where\tpipelines
run).\tThis ConfigMap contains object storage configuration,
as well as pipeline root (object store root path where artifacts
will be uploaded) configuration. Currently this ConfigMap *must*
be named \"kfp-launcher\". We currently deploy a default copy
of the kfp-launcher ConfigMap via DSPO, but a user may want
to provide their own ConfigMap configuration, so that they can
specify multiple object storage sources and paths."
type: string
customServerConfigMap:
description: CustomServerConfig is a custom config file that you
can provide for the api server to use instead.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apiVersion: v1
data:
{{ if .APIServer.CustomKfpLauncherConfigMap }}
{{.CustomKfpLauncherConfigMapData}}
{{ else }}
{{ if .ObjectStorageConnection.BasePath }}
defaultPipelineRoot: s3://{{.ObjectStorageConnection.Bucket}}/{{.ObjectStorageConnection.BasePath}}
{{ else }}
Expand All @@ -13,6 +16,7 @@ data:
secretName: {{.ObjectStorageConnection.CredentialsSecret.SecretName}}
accessKeyKey: {{.ObjectStorageConnection.CredentialsSecret.AccessKey}}
secretKeyKey: {{.ObjectStorageConnection.CredentialsSecret.SecretKey}}
{{ end }}
kind: ConfigMap
metadata:
name: kfp-launcher
Expand Down
1 change: 1 addition & 0 deletions config/samples/v2/dspa-all-fields/dspa_all_fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ metadata:
spec:
dspVersion: v2
apiServer:
customKfpLauncherConfigMap: configmapname
deploy: true
enableSamplePipeline: true
image: quay.io/opendatahub/ds-pipelines-api-server:latest
Expand Down
20 changes: 20 additions & 0 deletions controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type DSPAParams struct {
Minio *dspa.Minio
MLMD *dspa.MLMD
WorkflowController *dspa.WorkflowController
CustomKfpLauncherConfigMapData string
DBConnection
ObjectStorageConnection

Expand Down Expand Up @@ -646,6 +647,25 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
}
}

if p.APIServer.CustomKfpLauncherConfigMap != "" {
cm, err := util.GetConfigMap(ctx, p.APIServer.CustomKfpLauncherConfigMap, p.Namespace, client)
if err != nil {
// If the custom kfp-launcher ConfigMap is not available, that is ok. Just log it and move along.
if !apierrs.IsNotFound(err) {
log.Error(err, fmt.Sprintf("Error fetching ConfigMap referenced by CustomKfpLauncherConfig: [%s]", p.APIServer.CustomKfpLauncherConfigMap))
}
} else {
// when setting a map into the `data` field of a ConfigMap, text/template works well with a json object
jsonData, err := json.Marshal(cm.Data)
if err != nil {
// If the custom kfp-launcher ConfigMap can't be read, that is ok. Just log it and move along.
log.Error(err, fmt.Sprintf("Error reading data of ConfigMap referenced by CustomKfpLauncherConfig: [%s]", p.APIServer.CustomKfpLauncherConfigMap))
} else {
p.CustomKfpLauncherConfigMapData = string(jsonData)
}
}
}

// 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.
Expand Down

0 comments on commit 167bb24

Please sign in to comment.