From d10b3c123422122a9121d961f12260f847e39ca6 Mon Sep 17 00:00:00 2001 From: Josep-Sampe-Domenech Date: Wed, 24 Jan 2024 17:30:23 +0100 Subject: [PATCH 1/6] Update kfp backend and kubernetes sdk to support ImagePullSecrets --- backend/src/v2/driver/driver.go | 5 + backend/src/v2/driver/driver_test.go | 66 +++++++++++ .../python/kfp/kubernetes/__init__.py | 2 + .../python/kfp/kubernetes/image.py | 48 ++++++++ .../test/snapshot/data/image_pull_secrets.py | 32 +++++ .../snapshot/data/image_pull_secrets.yaml | 57 +++++++++ .../test/unit/test_image_pull_secrets.py | 111 ++++++++++++++++++ 7 files changed, 321 insertions(+) create mode 100644 kubernetes_platform/python/kfp/kubernetes/image.py create mode 100644 kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py create mode 100644 kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml create mode 100644 kubernetes_platform/python/test/unit/test_image_pull_secrets.py diff --git a/backend/src/v2/driver/driver.go b/backend/src/v2/driver/driver.go index adf626dfeab..12184d18784 100644 --- a/backend/src/v2/driver/driver.go +++ b/backend/src/v2/driver/driver.go @@ -512,6 +512,11 @@ func extendPodSpecPatch( } } + // Get image pull secret information + for _, imagePullSecret := range kubernetesExecutorConfig.GetImagePullSecret() { + podSpec.ImagePullSecrets = append(podSpec.ImagePullSecrets, k8score.LocalObjectReference{Name: imagePullSecret.GetSecretName()}) + } + return nil } diff --git a/backend/src/v2/driver/driver_test.go b/backend/src/v2/driver/driver_test.go index ec8516fb34d..ff950cda13c 100644 --- a/backend/src/v2/driver/driver_test.go +++ b/backend/src/v2/driver/driver_test.go @@ -605,3 +605,69 @@ func Test_extendPodSpecPatch_Secret(t *testing.T) { }) } } + +func Test_extendPodSpecPatch_ImagePullSecrets(t *testing.T) { + tests := []struct { + name string + k8sExecCfg *kubernetesplatform.KubernetesExecutorConfig + expected *k8score.PodSpec + }{ + { + "Valid - SecretA and SecretB", + &kubernetesplatform.KubernetesExecutorConfig{ + ImagePullSecret: []*kubernetesplatform.ImagePullSecret{ + {SecretName: "SecretA"}, + {SecretName: "SecretB"}, + }, + }, + &k8score.PodSpec{ + Containers: []k8score.Container{ + { + Name: "main", + }, + }, + ImagePullSecrets: []k8score.LocalObjectReference{ + {Name: "SecretA"}, + {Name: "SecretB"}, + }, + }, + }, + { + "Valid - No ImagePullSecrets", + &kubernetesplatform.KubernetesExecutorConfig{ + ImagePullSecret: []*kubernetesplatform.ImagePullSecret{}, + }, + &k8score.PodSpec{ + Containers: []k8score.Container{ + { + Name: "main", + }, + }, + }, + }, + { + "Valid - empty", + &kubernetesplatform.KubernetesExecutorConfig{}, + &k8score.PodSpec{ + Containers: []k8score.Container{ + { + Name: "main", + }, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := &k8score.PodSpec{Containers: []k8score.Container{ + { + Name: "main", + }, + }} + err := extendPodSpecPatch(got, tt.k8sExecCfg, nil, nil) + assert.Nil(t, err) + assert.NotNil(t, got) + assert.Equal(t, tt.expected, got) + }) + } +} diff --git a/kubernetes_platform/python/kfp/kubernetes/__init__.py b/kubernetes_platform/python/kfp/kubernetes/__init__.py index 1022b153bed..4793c4bc4ef 100644 --- a/kubernetes_platform/python/kfp/kubernetes/__init__.py +++ b/kubernetes_platform/python/kfp/kubernetes/__init__.py @@ -21,6 +21,7 @@ 'use_secret_as_env', 'use_secret_as_volume', 'add_node_selector', + 'set_image_pull_secrets' ] from kfp.kubernetes.node_selector import add_node_selector @@ -29,3 +30,4 @@ from kfp.kubernetes.volume import CreatePVC from kfp.kubernetes.volume import DeletePVC from kfp.kubernetes.volume import mount_pvc +from kfp.kubernetes.image import set_image_pull_secrets diff --git a/kubernetes_platform/python/kfp/kubernetes/image.py b/kubernetes_platform/python/kfp/kubernetes/image.py new file mode 100644 index 00000000000..34ac55fd0df --- /dev/null +++ b/kubernetes_platform/python/kfp/kubernetes/image.py @@ -0,0 +1,48 @@ +# Copyright 2024 The Kubeflow Authors +# +# 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. + +from typing import List + +from google.protobuf import json_format +from kfp.dsl import PipelineTask +from kfp.kubernetes import common +from kfp.kubernetes import kubernetes_executor_config_pb2 as pb + + +def set_image_pull_secrets( + task: PipelineTask, + secret_names: List[str], +) -> PipelineTask: + """Set image pull secrets for a Kubernetes task. + + Args: + task: Pipeline task. + secret_names: List of image pull secret names. + + Returns: + Task object with updated image pull secret configuration. + """ + + msg = common.get_existing_kubernetes_config_as_message(task) + + # Assuming secret_names is a list of strings + image_pull_secrets = [ + pb.ImagePullSecret(name=secret_name) for secret_name in secret_names + ] + + msg.image_pull_secrets.extend(image_pull_secrets) + + task.platform_config['kubernetes'] = json_format.MessageToDict(msg) + + return task diff --git a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py new file mode 100644 index 00000000000..5f5ed0f6d4b --- /dev/null +++ b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py @@ -0,0 +1,32 @@ +# Copyright 2024 The Kubeflow Authors +# +# 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. + +from kfp import dsl +from kfp import kubernetes + + +@dsl.component +def comp(): + pass + + +@dsl.pipeline +def my_pipeline(): + task = comp() + kubernetes.set_image_pull_secrets(task, ['my-secret']) + + +if __name__ == '__main__': + from kfp import compiler + compiler.Compiler().compile(my_pipeline, __file__.replace('.py', '.yaml')) diff --git a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml new file mode 100644 index 00000000000..01c4ec6fd30 --- /dev/null +++ b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml @@ -0,0 +1,57 @@ +# PIPELINE DEFINITION +# Name: my-pipeline +components: + comp-comp: + executorLabel: exec-comp +deploymentSpec: + executors: + exec-comp: + container: + args: + - --executor_input + - '{{$}}' + - --function_to_execute + - comp + command: + - sh + - -c + - "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\ + \ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\ + \ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.6.0'\ + \ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\ + $0\" \"$@\"\n" + - sh + - -ec + - 'program_path=$(mktemp -d) + + + printf "%s" "$0" > "$program_path/ephemeral_component.py" + + _KFP_RUNTIME=true python3 -m kfp.dsl.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" + + ' + - "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\ + \ *\n\ndef comp():\n pass\n\n" + image: python:3.7 +pipelineInfo: + name: my-pipeline +root: + dag: + tasks: + comp: + cachingOptions: + enableCache: true + componentRef: + name: comp-comp + taskInfo: + name: comp +schemaVersion: 2.1.0 +sdkVersion: kfp-2.6.0 +--- +platforms: + kubernetes: + deploymentSpec: + executors: + exec-comp: + imagePullSecrets: + - name: my-secret diff --git a/kubernetes_platform/python/test/unit/test_image_pull_secrets.py b/kubernetes_platform/python/test/unit/test_image_pull_secrets.py new file mode 100644 index 00000000000..4aebf420f9d --- /dev/null +++ b/kubernetes_platform/python/test/unit/test_image_pull_secrets.py @@ -0,0 +1,111 @@ +# Copyright 2024 The Kubeflow Authors +# +# 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. + +from google.protobuf import json_format +from kfp import dsl +from kfp import kubernetes + + +class TestImagePullSecrets: + + def test_add_one(self): + + @dsl.pipeline + def my_pipeline(): + task = comp() + kubernetes.set_image_pull_secrets(task, ['secret-name']) + + assert json_format.MessageToDict(my_pipeline.platform_spec) == { + 'platforms': { + 'kubernetes': { + 'deploymentSpec': { + 'executors': { + 'exec-comp': { + 'imagePullSecrets': [{ + 'secretName': + 'secret-name' + }] + } + } + } + } + } + } + + def test_add_two(self): + + @dsl.pipeline + def my_pipeline(): + task = comp() + kubernetes.set_image_pull_secrets(task, ['secret-name1', 'secret-name2']) + + assert json_format.MessageToDict(my_pipeline.platform_spec) == { + 'platforms': { + 'kubernetes': { + 'deploymentSpec': { + 'executors': { + 'exec-comp': { + 'imagePullSecrets': [{ + 'secretName': + 'secret-name1' + }, { + 'secretName': + 'secret-name2' + }, + ] + } + } + } + } + } + } + + def test_respects_other_configuration(self): + + @dsl.pipeline + def my_pipeline(): + task = comp() + + # Load the secret as a volume + kubernetes.use_secret_as_volume( + task, secret_name='secret-name', mount_path='/mnt/my_vol') + + # Set image pull secrets for a task using secret names + kubernetes.set_image_pull_secrets(task, ['secret-name']) + + assert json_format.MessageToDict(my_pipeline.platform_spec) == { + 'platforms': { + 'kubernetes': { + 'deploymentSpec': { + 'executors': { + 'exec-comp': { + 'secretAsVolume': [{ + 'secretName': 'secret-name', + 'mountPath': '/mnt/my_vol' + }], + 'imagePullSecrets': [{ + 'secretName': + 'secret-name' + }] + } + } + } + } + } + } + + +@dsl.component +def comp(): + pass From 45d05e77118270d2ca514778ee41ec29a7fe7210 Mon Sep 17 00:00:00 2001 From: Josep-Sampe-Domenech Date: Wed, 7 Feb 2024 19:03:20 +0100 Subject: [PATCH 2/6] update go.mod go.sum and csv files --- backend/third_party_licenses/apiserver.csv | 1 + backend/third_party_licenses/driver.csv | 2 +- go.mod | 2 +- go.sum | 4 ++-- kubernetes_platform/python/kfp/kubernetes/image.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/third_party_licenses/apiserver.csv b/backend/third_party_licenses/apiserver.csv index defbefb63ed..fc0d0eccced 100644 --- a/backend/third_party_licenses/apiserver.csv +++ b/backend/third_party_licenses/apiserver.csv @@ -61,6 +61,7 @@ github.com/klauspost/cpuid,https://github.com/klauspost/cpuid/blob/v1.3.1/LICENS github.com/klauspost/pgzip,https://github.com/klauspost/pgzip/blob/v1.2.5/LICENSE,MIT github.com/kubeflow/pipelines/api/v2alpha1/go,https://github.com/kubeflow/pipelines/blob/758c91f76784/api/LICENSE,Apache-2.0 github.com/kubeflow/pipelines/backend,https://github.com/kubeflow/pipelines/blob/HEAD/LICENSE,Apache-2.0 +github.com/kubeflow/pipelines/kubernetes_platform/go/kubernetesplatform,https://github.com/kubeflow/pipelines/blob/f51dc39614e4/kubernetes_platform/LICENSE,Apache-2.0 github.com/kubeflow/pipelines/third_party/ml-metadata/go/ml_metadata,https://github.com/kubeflow/pipelines/blob/e1f0c010f800/third_party/ml-metadata/LICENSE,Apache-2.0 github.com/lann/builder,https://github.com/lann/builder/blob/47ae307949d0/LICENSE,MIT github.com/lann/ps,https://github.com/lann/ps/blob/62de8c46ede0/LICENSE,MIT diff --git a/backend/third_party_licenses/driver.csv b/backend/third_party_licenses/driver.csv index b05a884c4c2..9880cb0254b 100644 --- a/backend/third_party_licenses/driver.csv +++ b/backend/third_party_licenses/driver.csv @@ -31,7 +31,7 @@ github.com/josharian/intern,https://github.com/josharian/intern/blob/v1.0.0/lice github.com/json-iterator/go,https://github.com/json-iterator/go/blob/v1.1.12/LICENSE,MIT github.com/kubeflow/pipelines/api/v2alpha1/go,https://github.com/kubeflow/pipelines/blob/758c91f76784/api/LICENSE,Apache-2.0 github.com/kubeflow/pipelines/backend,https://github.com/kubeflow/pipelines/blob/HEAD/LICENSE,Apache-2.0 -github.com/kubeflow/pipelines/kubernetes_platform/go/kubernetesplatform,https://github.com/kubeflow/pipelines/blob/bd9f74e34de6/kubernetes_platform/LICENSE,Apache-2.0 +github.com/kubeflow/pipelines/kubernetes_platform/go/kubernetesplatform,https://github.com/kubeflow/pipelines/blob/f51dc39614e4/kubernetes_platform/LICENSE,Apache-2.0 github.com/kubeflow/pipelines/third_party/ml-metadata/go/ml_metadata,https://github.com/kubeflow/pipelines/blob/e1f0c010f800/third_party/ml-metadata/LICENSE,Apache-2.0 github.com/mailru/easyjson,https://github.com/mailru/easyjson/blob/v0.7.7/LICENSE,MIT github.com/modern-go/concurrent,https://github.com/modern-go/concurrent/blob/bacd9c7ef1dd/LICENSE,Apache-2.0 diff --git a/go.mod b/go.mod index 2140e27775d..b5ab01fd94b 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.4 // indirect github.com/kubeflow/pipelines/api v0.0.0-20230331215358-758c91f76784 - github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20230404213301-bd9f74e34de6 + github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20240207171236-f51dc39614e4 github.com/kubeflow/pipelines/third_party/ml-metadata v0.0.0-20230810215105-e1f0c010f800 github.com/lestrrat-go/strftime v1.0.4 github.com/mattn/go-sqlite3 v1.14.16 diff --git a/go.sum b/go.sum index bef3f379d66..9fcebdf3c77 100644 --- a/go.sum +++ b/go.sum @@ -936,8 +936,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ktrysmt/go-bitbucket v0.9.32/go.mod h1:FWxy2UK7GlK5b0NSJGc5hPqnssVlkNnsChvyuOf/Xno= github.com/kubeflow/pipelines/api v0.0.0-20230331215358-758c91f76784 h1:ZVCoqnKnC2vctD7AqAHbWf05qw15VO5XSxCqkjObwtw= github.com/kubeflow/pipelines/api v0.0.0-20230331215358-758c91f76784/go.mod h1:T7TOQB36gGe97yUdfVAnYK5uuT0+uQbLNHDUHxYkmE4= -github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20230404213301-bd9f74e34de6 h1:ApWW5ZH45ruvQCmkp7RewHlPKGwqBNSSRxEHGJFiAOA= -github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20230404213301-bd9f74e34de6/go.mod h1:CJkKr356RlpZP/gQRuHf3Myrn1qJtoUVe4EMCmtwarg= +github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20240207171236-f51dc39614e4 h1:4WGf/JTH2Pks3A1fru2lk2u8gO/MR3g7tPJC7OXhAzk= +github.com/kubeflow/pipelines/kubernetes_platform v0.0.0-20240207171236-f51dc39614e4/go.mod h1:CJkKr356RlpZP/gQRuHf3Myrn1qJtoUVe4EMCmtwarg= github.com/kubeflow/pipelines/third_party/ml-metadata v0.0.0-20230810215105-e1f0c010f800 h1:YAW+X9xCW8Yq5tQaBBQaLTNU9CJj8Nr7lx1+k66ZHJ0= github.com/kubeflow/pipelines/third_party/ml-metadata v0.0.0-20230810215105-e1f0c010f800/go.mod h1:chIDffBaVQ/asNl1pTTdbAymYcuBKf8BR3YtSP+3FEU= github.com/labstack/echo v3.2.1+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= diff --git a/kubernetes_platform/python/kfp/kubernetes/image.py b/kubernetes_platform/python/kfp/kubernetes/image.py index 34ac55fd0df..cee3a6adf11 100644 --- a/kubernetes_platform/python/kfp/kubernetes/image.py +++ b/kubernetes_platform/python/kfp/kubernetes/image.py @@ -38,7 +38,7 @@ def set_image_pull_secrets( # Assuming secret_names is a list of strings image_pull_secrets = [ - pb.ImagePullSecret(name=secret_name) for secret_name in secret_names + pb.ImagePullSecret(secret_name=secret_name) for secret_name in secret_names ] msg.image_pull_secrets.extend(image_pull_secrets) From 0f03b9c1d52614b0f2d8e7142f5d48ac1962f39c Mon Sep 17 00:00:00 2001 From: Josep-Sampe-Domenech Date: Wed, 7 Feb 2024 19:28:36 +0100 Subject: [PATCH 3/6] update image_pull_secret method name --- kubernetes_platform/python/kfp/kubernetes/__init__.py | 4 ++-- kubernetes_platform/python/kfp/kubernetes/image.py | 6 +++--- .../python/test/snapshot/data/image_pull_secrets.py | 2 +- .../python/test/snapshot/data/image_pull_secrets.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kubernetes_platform/python/kfp/kubernetes/__init__.py b/kubernetes_platform/python/kfp/kubernetes/__init__.py index 4793c4bc4ef..26923d28e78 100644 --- a/kubernetes_platform/python/kfp/kubernetes/__init__.py +++ b/kubernetes_platform/python/kfp/kubernetes/__init__.py @@ -21,7 +21,7 @@ 'use_secret_as_env', 'use_secret_as_volume', 'add_node_selector', - 'set_image_pull_secrets' + 'set_image_pull_secret' ] from kfp.kubernetes.node_selector import add_node_selector @@ -30,4 +30,4 @@ from kfp.kubernetes.volume import CreatePVC from kfp.kubernetes.volume import DeletePVC from kfp.kubernetes.volume import mount_pvc -from kfp.kubernetes.image import set_image_pull_secrets +from kfp.kubernetes.image import set_image_pull_secret diff --git a/kubernetes_platform/python/kfp/kubernetes/image.py b/kubernetes_platform/python/kfp/kubernetes/image.py index cee3a6adf11..d691afc7533 100644 --- a/kubernetes_platform/python/kfp/kubernetes/image.py +++ b/kubernetes_platform/python/kfp/kubernetes/image.py @@ -20,7 +20,7 @@ from kfp.kubernetes import kubernetes_executor_config_pb2 as pb -def set_image_pull_secrets( +def set_image_pull_secret( task: PipelineTask, secret_names: List[str], ) -> PipelineTask: @@ -37,11 +37,11 @@ def set_image_pull_secrets( msg = common.get_existing_kubernetes_config_as_message(task) # Assuming secret_names is a list of strings - image_pull_secrets = [ + image_pull_secret = [ pb.ImagePullSecret(secret_name=secret_name) for secret_name in secret_names ] - msg.image_pull_secrets.extend(image_pull_secrets) + msg.image_pull_secret.extend(image_pull_secret) task.platform_config['kubernetes'] = json_format.MessageToDict(msg) diff --git a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py index 5f5ed0f6d4b..33e18d10eae 100644 --- a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py +++ b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py @@ -24,7 +24,7 @@ def comp(): @dsl.pipeline def my_pipeline(): task = comp() - kubernetes.set_image_pull_secrets(task, ['my-secret']) + kubernetes.set_image_pull_secret(task, ['my-secret']) if __name__ == '__main__': diff --git a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml index 01c4ec6fd30..52c7f987a99 100644 --- a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml +++ b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.yaml @@ -53,5 +53,5 @@ platforms: deploymentSpec: executors: exec-comp: - imagePullSecrets: - - name: my-secret + imagePullSecret: + - secretName: my-secret From 0dd0ec6bd58d71ff10fd32d19a010e1ad5d0acae Mon Sep 17 00:00:00 2001 From: Josep-Sampe-Domenech Date: Wed, 7 Feb 2024 19:40:30 +0100 Subject: [PATCH 4/6] update unit tests --- .../python/test/unit/test_image_pull_secrets.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kubernetes_platform/python/test/unit/test_image_pull_secrets.py b/kubernetes_platform/python/test/unit/test_image_pull_secrets.py index 4aebf420f9d..5dbc86bf159 100644 --- a/kubernetes_platform/python/test/unit/test_image_pull_secrets.py +++ b/kubernetes_platform/python/test/unit/test_image_pull_secrets.py @@ -17,14 +17,14 @@ from kfp import kubernetes -class TestImagePullSecrets: +class TestImagePullSecret: def test_add_one(self): @dsl.pipeline def my_pipeline(): task = comp() - kubernetes.set_image_pull_secrets(task, ['secret-name']) + kubernetes.set_image_pull_secret(task, ['secret-name']) assert json_format.MessageToDict(my_pipeline.platform_spec) == { 'platforms': { @@ -32,7 +32,7 @@ def my_pipeline(): 'deploymentSpec': { 'executors': { 'exec-comp': { - 'imagePullSecrets': [{ + 'imagePullSecret': [{ 'secretName': 'secret-name' }] @@ -48,7 +48,7 @@ def test_add_two(self): @dsl.pipeline def my_pipeline(): task = comp() - kubernetes.set_image_pull_secrets(task, ['secret-name1', 'secret-name2']) + kubernetes.set_image_pull_secret(task, ['secret-name1', 'secret-name2']) assert json_format.MessageToDict(my_pipeline.platform_spec) == { 'platforms': { @@ -56,7 +56,7 @@ def my_pipeline(): 'deploymentSpec': { 'executors': { 'exec-comp': { - 'imagePullSecrets': [{ + 'imagePullSecret': [{ 'secretName': 'secret-name1' }, { @@ -82,7 +82,7 @@ def my_pipeline(): task, secret_name='secret-name', mount_path='/mnt/my_vol') # Set image pull secrets for a task using secret names - kubernetes.set_image_pull_secrets(task, ['secret-name']) + kubernetes.set_image_pull_secret(task, ['secret-name']) assert json_format.MessageToDict(my_pipeline.platform_spec) == { 'platforms': { @@ -94,7 +94,7 @@ def my_pipeline(): 'secretName': 'secret-name', 'mountPath': '/mnt/my_vol' }], - 'imagePullSecrets': [{ + 'imagePullSecret': [{ 'secretName': 'secret-name' }] From e3d37dce2ddf3735710552315ee3eb2903652c46 Mon Sep 17 00:00:00 2001 From: Josep-Sampe-Domenech Date: Wed, 7 Feb 2024 20:19:55 +0100 Subject: [PATCH 5/6] update apiserver.csv file --- backend/third_party_licenses/apiserver.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/third_party_licenses/apiserver.csv b/backend/third_party_licenses/apiserver.csv index fc0d0eccced..defbefb63ed 100644 --- a/backend/third_party_licenses/apiserver.csv +++ b/backend/third_party_licenses/apiserver.csv @@ -61,7 +61,6 @@ github.com/klauspost/cpuid,https://github.com/klauspost/cpuid/blob/v1.3.1/LICENS github.com/klauspost/pgzip,https://github.com/klauspost/pgzip/blob/v1.2.5/LICENSE,MIT github.com/kubeflow/pipelines/api/v2alpha1/go,https://github.com/kubeflow/pipelines/blob/758c91f76784/api/LICENSE,Apache-2.0 github.com/kubeflow/pipelines/backend,https://github.com/kubeflow/pipelines/blob/HEAD/LICENSE,Apache-2.0 -github.com/kubeflow/pipelines/kubernetes_platform/go/kubernetesplatform,https://github.com/kubeflow/pipelines/blob/f51dc39614e4/kubernetes_platform/LICENSE,Apache-2.0 github.com/kubeflow/pipelines/third_party/ml-metadata/go/ml_metadata,https://github.com/kubeflow/pipelines/blob/e1f0c010f800/third_party/ml-metadata/LICENSE,Apache-2.0 github.com/lann/builder,https://github.com/lann/builder/blob/47ae307949d0/LICENSE,MIT github.com/lann/ps,https://github.com/lann/ps/blob/62de8c46ede0/LICENSE,MIT From 45e4ffaf19bd94c0b97ea6aec54fd92c64296963 Mon Sep 17 00:00:00 2001 From: Josep-Sampe-Domenech Date: Thu, 8 Feb 2024 14:23:30 +0100 Subject: [PATCH 6/6] update set_image_pull_secrets name --- kubernetes_platform/python/kfp/kubernetes/__init__.py | 4 ++-- kubernetes_platform/python/kfp/kubernetes/image.py | 2 +- .../python/test/snapshot/data/image_pull_secrets.py | 2 +- .../python/test/unit/test_image_pull_secrets.py | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kubernetes_platform/python/kfp/kubernetes/__init__.py b/kubernetes_platform/python/kfp/kubernetes/__init__.py index 26923d28e78..4793c4bc4ef 100644 --- a/kubernetes_platform/python/kfp/kubernetes/__init__.py +++ b/kubernetes_platform/python/kfp/kubernetes/__init__.py @@ -21,7 +21,7 @@ 'use_secret_as_env', 'use_secret_as_volume', 'add_node_selector', - 'set_image_pull_secret' + 'set_image_pull_secrets' ] from kfp.kubernetes.node_selector import add_node_selector @@ -30,4 +30,4 @@ from kfp.kubernetes.volume import CreatePVC from kfp.kubernetes.volume import DeletePVC from kfp.kubernetes.volume import mount_pvc -from kfp.kubernetes.image import set_image_pull_secret +from kfp.kubernetes.image import set_image_pull_secrets diff --git a/kubernetes_platform/python/kfp/kubernetes/image.py b/kubernetes_platform/python/kfp/kubernetes/image.py index d691afc7533..e7e7853b838 100644 --- a/kubernetes_platform/python/kfp/kubernetes/image.py +++ b/kubernetes_platform/python/kfp/kubernetes/image.py @@ -20,7 +20,7 @@ from kfp.kubernetes import kubernetes_executor_config_pb2 as pb -def set_image_pull_secret( +def set_image_pull_secrets( task: PipelineTask, secret_names: List[str], ) -> PipelineTask: diff --git a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py index 33e18d10eae..5f5ed0f6d4b 100644 --- a/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py +++ b/kubernetes_platform/python/test/snapshot/data/image_pull_secrets.py @@ -24,7 +24,7 @@ def comp(): @dsl.pipeline def my_pipeline(): task = comp() - kubernetes.set_image_pull_secret(task, ['my-secret']) + kubernetes.set_image_pull_secrets(task, ['my-secret']) if __name__ == '__main__': diff --git a/kubernetes_platform/python/test/unit/test_image_pull_secrets.py b/kubernetes_platform/python/test/unit/test_image_pull_secrets.py index 5dbc86bf159..3aff349af82 100644 --- a/kubernetes_platform/python/test/unit/test_image_pull_secrets.py +++ b/kubernetes_platform/python/test/unit/test_image_pull_secrets.py @@ -24,7 +24,7 @@ def test_add_one(self): @dsl.pipeline def my_pipeline(): task = comp() - kubernetes.set_image_pull_secret(task, ['secret-name']) + kubernetes.set_image_pull_secrets(task, ['secret-name']) assert json_format.MessageToDict(my_pipeline.platform_spec) == { 'platforms': { @@ -48,7 +48,7 @@ def test_add_two(self): @dsl.pipeline def my_pipeline(): task = comp() - kubernetes.set_image_pull_secret(task, ['secret-name1', 'secret-name2']) + kubernetes.set_image_pull_secrets(task, ['secret-name1', 'secret-name2']) assert json_format.MessageToDict(my_pipeline.platform_spec) == { 'platforms': { @@ -82,7 +82,7 @@ def my_pipeline(): task, secret_name='secret-name', mount_path='/mnt/my_vol') # Set image pull secrets for a task using secret names - kubernetes.set_image_pull_secret(task, ['secret-name']) + kubernetes.set_image_pull_secrets(task, ['secret-name']) assert json_format.MessageToDict(my_pipeline.platform_spec) == { 'platforms': {