Skip to content

Commit

Permalink
feat(deployment): configurable v2 compatible mode default pipeline ro…
Browse files Browse the repository at this point in the history
…ot. Part of #5680. Fixes #5704 (#5750)

* feat(deployment): configurable v2 compatible mode default pipeline root

* clarify documentation
  • Loading branch information
Bobgy authored Jun 2, 2021
1 parent cf2807c commit adc1951
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 6 deletions.
7 changes: 7 additions & 0 deletions manifests/kustomize/base/installs/generic/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ vars:
apiVersion: v1
fieldref:
fieldpath: data.bucketName
- name: kfp-default-pipeline-root
objref:
kind: ConfigMap
name: pipeline-install-config
apiVersion: v1
fieldref:
fieldpath: data.defaultPipelineRoot
configurations:
- params.yaml
2 changes: 2 additions & 0 deletions manifests/kustomize/base/installs/generic/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
varReference:
- path: data/config
kind: ConfigMap
- path: data/defaultPipelineRoot
kind: ConfigMap
- path: metadata/name
kind: Application
- path: spec/descriptor/version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ kind: ConfigMap
metadata:
name: pipeline-install-config
data:
warning: |
1. Do not use kubectl to edit this configmap, because some values are used
during kustomize build. Instead, change the configmap and apply the entire
kustomize manifests again.
2. After updating the configmap, some deployments may need to be restarted
until the changes take effect. A quick way to restart all deployments in a
namespace: `kubectl rollout restart deployment -n <your-namespace>`.
appName: pipeline
appVersion: 1.6.0
dbHost: mysql
Expand All @@ -11,6 +19,36 @@ data:
cacheDb: cachedb
pipelineDb: mlpipeline
bucketName: mlpipeline

## defaultPipelineRoot: Optional. Default pipeline root in v2 compatible mode.
## https://www.kubeflow.org/docs/components/pipelines/sdk/v2/v2-compatibility/
##
## If the field is not set, kfp-launcher configmaps won't be created and
## v2 compatible mode defaults to minio://mlpipeline/v2/artifacts as pipeline
## root.
##
## When not in Kubeflow Pipelines multi-user mode, the config works as you
## would normally expect.
##
## In Kubeflow Pipelines multi-user mode, the config creates default
## kfp-launcher configmaps in each user's namespace. Users can edit the
## kfp-launcher configmap's defaultPipelineRoot field afterwards to configure
## namespace-specific default pipeline root. The namespace specific changes in
## kfp-launcher configmap won't be overridden by pipeline-install-config.
##
## Caveat: when you update the config from a non-empty value, only new
## namespaces get the updated config by default. Owners of existing namespaces
## must delete the kfp-launcher configmap to get the new default config value.
##
## Examples:
## defaultPipelineRoot: minio://mlpipeline/v2/artifacts
## defaultPipelineRoot: gs://your-bucket/path/to/artifacts
## defaultPipelineRoot: s3://your-bucket/path/to/artifacts
##
## V2 Compatible Mode Feature stage:
## [Beta](https://github.com/kubeflow/pipelines/blob/master/docs/release/feature-stages.md#beta)
defaultPipelineRoot: ""

## autoUpdatePipelineDefaultVersion: States if the pipeline version
## should be updated by defult for a versioned pipeline or not when a new
## version is uploaded. This sets the deployment wide definition.
Expand All @@ -20,7 +58,7 @@ data:
## cluster will be used. Valid values are UTC, Local or values according to
## the IANA Time Zone database, such as "America/New_York" and "Asia/Shanghai".
## Feature stage:
## [Alpha](https://github.com/kubeflow/pipelines/blob/07328e5094ac2981d3059314cc848fbb71437a76/docs/release/feature-stages.md#alpha)
## [Alpha](https://github.com/kubeflow/pipelines/blob/master/docs/release/feature-stages.md#alpha)
cronScheduleTimezone: "UTC"
## cacheImage is the image that the mutating webhook will use to patch
## cached steps with. Will be used to echo a message announcing that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ spec:
configMapKeyRef:
name: pipeline-install-config
key: appVersion
- name: KFP_DEFAULT_PIPELINE_ROOT
valueFrom:
configMapKeyRef:
optional: true
name: pipeline-install-config
key: defaultPipelineRoot
- name: MINIO_ACCESS_KEY
valueFrom:
secretKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import base64

kfp_version = os.environ["KFP_VERSION"]
# KFP_DEFAULT_PIPELINE_ROOT is optional
kfp_default_pipeline_root = os.environ.get("KFP_DEFAULT_PIPELINE_ROOT")
disable_istio_sidecar = os.environ.get("DISABLE_ISTIO_SIDECAR") == "true"
mlpipeline_minio_access_key = base64.b64encode(
bytes(os.environ.get("MINIO_ACCESS_KEY"), 'utf-8')).decode('utf-8')
Expand All @@ -27,17 +29,35 @@

class Controller(BaseHTTPRequestHandler):
def sync(self, parent, children):
# parent is a namespace
namespace = parent.get("metadata", {}).get("name")
pipeline_enabled = parent.get("metadata", {}).get(
"labels", {}).get("pipelines.kubeflow.org/enabled")

if pipeline_enabled != "true":
return {"status": {}, "children": []}

desired_configmap_count = 1
desired_resources = []
if kfp_default_pipeline_root:
desired_configmap_count = 2
desired_resources += [{
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {
"name": "kfp-launcher",
"namespace": namespace,
},
"data": {
"defaultPipelineRoot": kfp_default_pipeline_root,
},
}]

# Compute status based on observed state.
desired_status = {
"kubeflow-pipelines-ready": \
len(children["Secret.v1"]) == 1 and \
len(children["ConfigMap.v1"]) == 1 and \
len(children["ConfigMap.v1"]) == desired_configmap_count and \
len(children["Deployment.apps/v1"]) == 2 and \
len(children["Service.v1"]) == 2 and \
len(children["DestinationRule.networking.istio.io/v1alpha3"]) == 1 and \
Expand All @@ -46,9 +66,7 @@ def sync(self, parent, children):
}

# Generate the desired child object(s).
# parent is a namespace
namespace = parent.get("metadata", {}).get("name")
desired_resources = [
desired_resources += [
{
"apiVersion": "v1",
"kind": "ConfigMap",
Expand Down
6 changes: 6 additions & 0 deletions manifests/kustomize/base/pipeline/kfp-launcher-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: kfp-launcher
data:
defaultPipelineRoot: $(kfp-default-pipeline-root)
1 change: 1 addition & 0 deletions manifests/kustomize/base/pipeline/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resources:
- pipeline-runner-sa.yaml
- container-builder-sa.yaml
- viewer-sa.yaml
- kfp-launcher-configmap.yaml
images:
- name: gcr.io/ml-pipeline/api-server
newTag: 1.6.0
Expand Down
2 changes: 1 addition & 1 deletion manifests/kustomize/hack/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ kustomization_yamls_v3=(
)
for path in "${kustomization_yamls_v3[@]}"
do
kustomize build --load_restrictor none "${MANIFESTS_DIR}/${path}" >/dev/null
kustomize build "${MANIFESTS_DIR}/${path}" >/dev/null
done

# verify these manifests work with kpt
Expand Down

0 comments on commit adc1951

Please sign in to comment.