From 7a14e326402e59bff3d836132b9369b7a5ac3a69 Mon Sep 17 00:00:00 2001 From: Ricardo Martinelli de Oliveira Date: Wed, 18 Oct 2023 21:04:56 -0300 Subject: [PATCH] feat(Tekton-compiler): Add env vars in kfp-driver to parametrize Object storage host and port (#1378) Co-authored-by: Tommy Li --- .../v2/compiler/tektoncompiler/container.go | 33 ++++++++++++++++- .../tektoncompiler/testdata/exit_handler.yaml | 12 +++++++ .../tektoncompiler/testdata/hello_world.yaml | 4 +++ .../tektoncompiler/testdata/loop_static.yaml | 12 +++++++ .../testdata/mnist_pipeline.yaml | 36 +++++++++++++++++++ .../tektoncompiler/testdata/nestedloop.yaml | 16 +++++++++ 6 files changed, 112 insertions(+), 1 deletion(-) diff --git a/backend/src/v2/compiler/tektoncompiler/container.go b/backend/src/v2/compiler/tektoncompiler/container.go index 0d5ba5f5e2..a40710f5cc 100644 --- a/backend/src/v2/compiler/tektoncompiler/container.go +++ b/backend/src/v2/compiler/tektoncompiler/container.go @@ -38,6 +38,8 @@ const ( MLPipelineServiceHost = "ml-pipeline.kubeflow.svc.cluster.local" MLPipelineServicePort = "8887" LauncherImage = "gcr.io/ml-pipeline/kfp-launcher@sha256:6641bf94acaeec03ee7e231241800fce2f0ad92eee25371bd5248ca800a086d7" + MinioServiceHost = "minio-service.kubeflow.svc.cluster.local" + MinioServicePort = "9000" ) var ( @@ -47,6 +49,8 @@ var ( mlPipelineServiceHost = MLPipelineServiceHost mlPipelineServicePort = MLPipelineServicePort launcherImage = LauncherImage + minioServiceHost = MinioServiceHost + minioServicePort = MinioServicePort ) func initEnvVars() { @@ -70,11 +74,18 @@ func initEnvVars() { if metadataGRPCServicePort == "" { metadataGRPCServicePort = MetadataGPRCServicePort } - launcherImage = os.Getenv("V2_LAUNCHER_IMAGE") if launcherImage == "" { launcherImage = LauncherImage } + minioServiceHost = os.Getenv("MINIO_SERVICE_SERVICE_HOST") + if minioServiceHost == "" { + minioServiceHost = MinioServiceHost + } + minioServicePort = os.Getenv("MINIO_SERVICE_SERVICE_PORT") + if minioServicePort == "" { + minioServicePort = MinioServicePort + } envVarInit = true } @@ -113,6 +124,20 @@ func GetLauncherImage() string { return launcherImage } +func GetMinioHost() string { + if !envVarInit { + initEnvVars() + } + return minioServiceHost +} + +func GetMinioPort() string { + if !envVarInit { + initEnvVars() + } + return minioServicePort +} + // add KubernetesSpec for the container of the component func (c *pipelinerunCompiler) AddKubernetesSpec(name string, kubernetesSpec *structpb.Struct) error { err := c.saveKubernetesSpec(name, kubernetesSpec) @@ -438,6 +463,12 @@ func (c *pipelinerunCompiler) containerExecutorTemplate( }, { Name: "ML_PIPELINE_SERVICE_PORT_GRPC", Value: GetMLPipelinePort(), + }, { + Name: "MINIO_SERVICE_SERVICE_HOST", + Value: GetMinioHost(), + }, { + Name: "MINIO_SERVICE_SERVICE_PORT", + Value: GetMinioPort(), }}, }, }, diff --git a/backend/src/v2/compiler/tektoncompiler/testdata/exit_handler.yaml b/backend/src/v2/compiler/tektoncompiler/testdata/exit_handler.yaml index 328a4c4ef6..b46e67575b 100755 --- a/backend/src/v2/compiler/tektoncompiler/testdata/exit_handler.yaml +++ b/backend/src/v2/compiler/tektoncompiler/testdata/exit_handler.yaml @@ -172,6 +172,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -351,6 +355,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -507,6 +515,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap diff --git a/backend/src/v2/compiler/tektoncompiler/testdata/hello_world.yaml b/backend/src/v2/compiler/tektoncompiler/testdata/hello_world.yaml index 2f4f29942d..ed1a834b0f 100644 --- a/backend/src/v2/compiler/tektoncompiler/testdata/hello_world.yaml +++ b/backend/src/v2/compiler/tektoncompiler/testdata/hello_world.yaml @@ -143,6 +143,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap diff --git a/backend/src/v2/compiler/tektoncompiler/testdata/loop_static.yaml b/backend/src/v2/compiler/tektoncompiler/testdata/loop_static.yaml index cdfbd78608..278c504e60 100644 --- a/backend/src/v2/compiler/tektoncompiler/testdata/loop_static.yaml +++ b/backend/src/v2/compiler/tektoncompiler/testdata/loop_static.yaml @@ -227,6 +227,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -386,6 +390,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -587,6 +595,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap diff --git a/backend/src/v2/compiler/tektoncompiler/testdata/mnist_pipeline.yaml b/backend/src/v2/compiler/tektoncompiler/testdata/mnist_pipeline.yaml index b0e3254b2d..6fd9ca8fe9 100755 --- a/backend/src/v2/compiler/tektoncompiler/testdata/mnist_pipeline.yaml +++ b/backend/src/v2/compiler/tektoncompiler/testdata/mnist_pipeline.yaml @@ -163,6 +163,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -343,6 +347,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -477,6 +485,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -815,6 +827,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -1032,6 +1048,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -1193,6 +1213,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -1379,6 +1403,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -1506,6 +1534,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -1687,6 +1719,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap diff --git a/backend/src/v2/compiler/tektoncompiler/testdata/nestedloop.yaml b/backend/src/v2/compiler/tektoncompiler/testdata/nestedloop.yaml index 97504e9b54..7418dd63ec 100644 --- a/backend/src/v2/compiler/tektoncompiler/testdata/nestedloop.yaml +++ b/backend/src/v2/compiler/tektoncompiler/testdata/nestedloop.yaml @@ -162,6 +162,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -399,6 +403,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -611,6 +619,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap @@ -827,6 +839,10 @@ spec: value: ml-pipeline.kubeflow.svc.cluster.local - name: ML_PIPELINE_SERVICE_PORT_GRPC value: "8887" + - name: MINIO_SERVICE_SERVICE_HOST + value: "minio-service.kubeflow.svc.cluster.local" + - name: MINIO_SERVICE_SERVICE_PORT + value: "9000" envFrom: - configMapRef: name: metadata-grpc-configmap