forked from opendatahub-io/data-science-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add volumeop and volumesnapshot support (#93)
* add volumeop support workaround * add volumesnapshot workaround * update resourceop integration * add sorting to avoid randomness * fix bug * update sample * minor code cleanup
- Loading branch information
Showing
10 changed files
with
792 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2020 kubeflow.org | ||
# | ||
# 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. | ||
|
||
import kfp | ||
import kfp.dsl as dsl | ||
|
||
|
||
@dsl.pipeline( | ||
name="VolumeOp Basic", | ||
description="A Basic Example on VolumeOp Usage." | ||
) | ||
def volumeop_basic(size): | ||
vop = dsl.VolumeOp( | ||
name="create-pvc", | ||
resource_name="my-pvc", | ||
modes=dsl.VOLUME_MODE_RWO, | ||
size=size | ||
) | ||
|
||
cop = dsl.ContainerOp( | ||
name="cop", | ||
image="library/bash:4.4.23", | ||
command=["sh", "-c"], | ||
arguments=["echo foo > /mnt/file1"], | ||
pvolumes={"/mnt": vop.volume} | ||
) | ||
|
||
if __name__ == '__main__': | ||
# don't use top-level import of TektonCompiler to prevent monkey-patching KFP compiler when using KFP's dsl-compile | ||
from kfp_tekton.compiler import TektonCompiler | ||
TektonCompiler().compile(volumeop_basic, __file__.replace('.py', '.yaml')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Copyright 2020 kubeflow.org | ||
# | ||
# 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. | ||
|
||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: create-pvc | ||
spec: | ||
params: | ||
- description: Action on the resource | ||
name: action | ||
type: string | ||
- default: strategic | ||
description: Merge strategy when using action patch | ||
name: merge-strategy | ||
type: string | ||
- default: '' | ||
description: An express to retrieval data from resource. | ||
name: output | ||
type: string | ||
- default: '' | ||
description: A label selector express to decide if the action on resource is success. | ||
name: success-condition | ||
type: string | ||
- default: '' | ||
description: A label selector express to decide if the action on resource is failure. | ||
name: failure-condition | ||
type: string | ||
- default: index.docker.io/aipipeline/kubeclient:v0.0.2 | ||
description: Kubectl wrapper image | ||
name: image | ||
type: string | ||
- default: 'false' | ||
description: Enable set owner reference for created resource. | ||
name: set-ownerreference | ||
type: string | ||
- name: size | ||
results: | ||
- description: '{}' | ||
name: manifest | ||
- description: '{.metadata.name}' | ||
name: name | ||
- description: '{.status.capacity.storage}' | ||
name: size | ||
steps: | ||
- args: | ||
- --action=$(params.action) | ||
- --merge-strategy=$(params.merge-strategy) | ||
- "--manifest=apiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n name:\ | ||
\ $(PIPELINERUN)-my-pvc\nspec:\n accessModes:\n - ReadWriteOnce\n resources:\n\ | ||
\ requests:\n storage: $(inputs.params.size)\n" | ||
- --output=$(params.output) | ||
- --success-condition=$(params.success-condition) | ||
- --failure-condition=$(params.failure-condition) | ||
- --set-ownerreference=$(params.set-ownerreference) | ||
env: | ||
- name: PIPELINERUN | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.labels['tekton.dev/pipelineRun'] | ||
image: $(params.image) | ||
name: create-pvc | ||
resources: {} | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: cop | ||
spec: | ||
params: | ||
- name: create-pvc-name | ||
steps: | ||
- args: | ||
- echo foo > /mnt/file1 | ||
command: | ||
- sh | ||
- -c | ||
image: library/bash:4.4.23 | ||
name: cop | ||
volumeMounts: | ||
- mountPath: /mnt | ||
name: create-pvc | ||
volumes: | ||
- name: create-pvc | ||
persistentVolumeClaim: | ||
claimName: $(inputs.params.create-pvc-name) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
annotations: | ||
pipelines.kubeflow.org/pipeline_spec: '{"description": "A Basic Example on VolumeOp | ||
Usage.", "inputs": [{"name": "size"}], "name": "VolumeOp Basic"}' | ||
name: volumeop-basic | ||
spec: | ||
params: | ||
- name: size | ||
tasks: | ||
- name: create-pvc | ||
params: | ||
- name: action | ||
value: create | ||
- name: output | ||
value: "- name: manifest\n valueFrom: '{}'\n- name: name\n valueFrom: '{.metadata.name}'\n\ | ||
- name: size\n valueFrom: '{.status.capacity.storage}'\n" | ||
- name: set-ownerreference | ||
value: 'false' | ||
- name: size | ||
value: $(params.size) | ||
taskRef: | ||
name: create-pvc | ||
- name: cop | ||
params: | ||
- name: create-pvc-name | ||
value: $(tasks.create-pvc.results.name) | ||
taskRef: | ||
name: cop |
Oops, something went wrong.