Skip to content

Commit

Permalink
UPSTREAM: <carry>: add ability to mount self-signed certs to dsp v2
Browse files Browse the repository at this point in the history
Add ability to mount self-signed certs to dsp v2
  • Loading branch information
VaniHaripriya committed Feb 20, 2024
1 parent f3e082e commit 16b63f8
Showing 1 changed file with 43 additions and 14 deletions.
57 changes: 43 additions & 14 deletions backend/src/v2/compiler/argocompiler/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@
package argocompiler

import (
wfapi "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"fmt"
"os"

wfapi "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/kubeflow/pipelines/api/v2alpha1/go/pipelinespec"
"github.com/kubeflow/pipelines/backend/src/v2/component"
k8score "k8s.io/api/core/v1"
)

const (
volumeNameKFPLauncher = "kfp-launcher"
DefaultLauncherImage = "gcr.io/ml-pipeline/kfp-launcher@sha256:80cf120abd125db84fa547640fd6386c4b2a26936e0c2b04a7d3634991a850a4"
volumeNameCABUndle = "ca-bundle"
DefaultLauncherImage = "gcr.io/ml-pipeline/kfp-launcher@sha256:80cf120abd125db84fa547640fd6386c4b2a26936e0c2b04a7d3634991a850a4"
LauncherImageEnvVar = "V2_LAUNCHER_IMAGE"
DefaultDriverImage = "gcr.io/ml-pipeline/kfp-driver@sha256:8e60086b04d92b657898a310ca9757631d58547e76bbbb8bfc376d654bef1707"
DriverImageEnvVar = "V2_DRIVER_IMAGE"
DefaultDriverImage = "gcr.io/ml-pipeline/kfp-driver@sha256:8e60086b04d92b657898a310ca9757631d58547e76bbbb8bfc376d654bef1707"
DriverImageEnvVar = "V2_DRIVER_IMAGE"
)

func (c *workflowCompiler) Container(name string, component *pipelinespec.ComponentSpec, container *pipelinespec.PipelineDeploymentConfig_PipelineContainerSpec) error {
Expand Down Expand Up @@ -58,19 +61,19 @@ type containerDriverInputs struct {
}

func GetLauncherImage() string {
launcherImage := os.Getenv(LauncherImageEnvVar)
if launcherImage == "" {
launcherImage = DefaultLauncherImage
}
return launcherImage
launcherImage := os.Getenv(LauncherImageEnvVar)
if launcherImage == "" {
launcherImage = DefaultLauncherImage
}
return launcherImage
}

func GetDriverImage() string {
driverImage := os.Getenv(DriverImageEnvVar)
if driverImage == "" {
driverImage = DefaultDriverImage
}
return driverImage
driverImage := os.Getenv(DriverImageEnvVar)
if driverImage == "" {
driverImage = DefaultDriverImage
}
return driverImage
}

func (c *workflowCompiler) containerDriverTask(name string, inputs containerDriverInputs) (*wfapi.DAGTask, *containerDriverOutputs) {
Expand Down Expand Up @@ -273,6 +276,32 @@ func (c *workflowCompiler) addContainerExecutorTemplate() string {
Env: commonEnvs,
},
}
caBundleCfgMapName := os.Getenv("ARTIFACT_COPY_STEP_CABUNDLE_CONFIGMAP_NAME")
caBundleCfgMapKey := os.Getenv("ARTIFACT_COPY_STEP_CABUNDLE_CONFIGMAP_KEY")
caBundleMountPath := os.Getenv("ARTIFACT_COPY_STEP_CABUNDLE_MOUNTPATH")
if caBundleCfgMapName != "" && caBundleCfgMapKey != "" {
volume := k8score.Volume{
Name: volumeNameCABUndle,
VolumeSource: k8score.VolumeSource{
ConfigMap: &k8score.ConfigMapVolumeSource{
LocalObjectReference: k8score.LocalObjectReference{
Name: caBundleCfgMapName,
},
},
},
}

executor.Volumes = append(executor.Volumes, volume)

volumeMount := k8score.VolumeMount{
Name: volumeNameCABUndle,
MountPath: fmt.Sprintf("%s/%s", caBundleMountPath, caBundleCfgMapKey),
SubPath: caBundleCfgMapKey,
}

executor.Container.VolumeMounts = append(executor.Container.VolumeMounts, volumeMount)

}
c.templates[nameContainerImpl] = executor
c.wf.Spec.Templates = append(c.wf.Spec.Templates, *container, *executor)
return nameContainerExecutor
Expand Down

0 comments on commit 16b63f8

Please sign in to comment.