-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add volumeop and volumesnapshot support #93
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c927f25
add volumeop support workaround
Tomcli 5c00c02
add volumesnapshot workaround
Tomcli 3a60d75
update resourceop integration
Tomcli 4f12a2d
add sorting to avoid randomness
Tomcli 9bf62c2
fix bug
Tomcli 38332a7
update sample
Tomcli 88a5f0f
minor code cleanup
Tomcli f145b51
Merge branch 'master' into volumeop-support
Tomcli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks.