-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will allow copying content either into or out of a `TaskRun`, either to an existing volume or a newly created volume. The immediate use case is for copying a pipeline's workspace to be made available as the input for another pipeline's workspace without needing to deal with uploading everything to a bucket. The volume, whether already existing or created, will not be deleted at the end of the `PipelineRun`, unlike the artifact storage PVC. The Volume resource is a sub-type of the general Storage resource. Since this type will require the creation of a PVC to function (to be configurable later), this commit adds a Setup interface that PipelineResources can implement if they need to do setup that involves instantiating objects in Kube. This could be a place to later add features like caching, and also is the sort of design we'd expect once PipelineResources are extensible (PipelineResources will be free to do whatever setup they need). The behavior of this volume resource is: 1. For inputs, copy data _from_ the PVC to the workspace path 2. For outputs, copy data _to_ the PVC from the workspace path If a user does want to control where the data is copied from, they can: 1. Add a step that copies from the location they want to copy from on disk to /workspace/whatever 2. Use the "targetPath" argument in the PipelineResource to control the location the data is copied to (still relative to targetPath https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#controlling-where-resources-are-mounted) 3. Use `path` https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#overriding-where-resources-are-copied-from (tbd if we want to keep this feature post PVC) The underlying PVC will need to be created by the Task reonciler, if only a TaskRun is being used, or by the PipelineRun reconciler if a Pipeline is being used. The PipelineRun reconciler cannot delegate this to the TaskRun reconciler b/c when two different reconcilers create PVCs and Tekton is running on a regional GKE cluster, they can get created in different zones, resulting in a pod that tries to use both being unschedulable. fixes #1062 Co-authored-by: Dan Lorenc <lorenc.d@gmail.com> Co-authored-by: Christie Wilson <bobcatfish@gmail.com>
- Loading branch information
1 parent
c30f1d2
commit f414a5d
Showing
30 changed files
with
1,425 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: volume-resource-1 | ||
spec: | ||
type: storage | ||
params: | ||
- name: type | ||
value: volume | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: volume-resource-2 | ||
spec: | ||
type: storage | ||
params: | ||
- name: type | ||
value: volume | ||
- name: path | ||
value: special-folder | ||
--- | ||
# Task writes "some stuff" to a predefined path | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: create-files | ||
spec: | ||
outputs: | ||
# This Task uses two volume outputs to ensure that multiple volume | ||
# outputs can be used | ||
resources: | ||
- name: volume1 | ||
type: storage | ||
- name: volume2 | ||
type: storage | ||
steps: | ||
- name: write-new-stuff-1 | ||
image: ubuntu | ||
command: ['bash'] | ||
args: ['-c', 'echo some stuff1 > /workspace/output/volume1/stuff1'] | ||
- name: write-new-stuff-2 | ||
image: ubuntu | ||
command: ['bash'] | ||
args: ['-c', 'echo some stuff2 > /workspace/output/volume2/stuff2'] | ||
--- | ||
# Reads a file from a predefined path and writes as well | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: files-exist-and-add-new | ||
spec: | ||
inputs: | ||
resources: | ||
- name: volume1 | ||
type: storage | ||
targetPath: newpath | ||
- name: volume2 | ||
type: storage | ||
outputs: | ||
# This Task uses the same volume as an input and an output to ensure this works | ||
resources: | ||
- name: volume1 | ||
type: storage | ||
steps: | ||
- name: read1 | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: | ||
- '-c' | ||
- '[[ stuff1 == $(cat $(inputs.resources.volume1.path)/stuff1) ]]"' | ||
- name: read2 | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: | ||
- '-c' | ||
# TODO: should fail | ||
- '[[ stuff == $(cat $(inputs.resources.volume2.path)/stuff1) ]]"' | ||
- name: write-new-stuff-3 | ||
image: ubuntu | ||
command: ['bash'] | ||
args: ['-c', 'echo some stuff3 > /workspace/output/volume1/stuff3'] | ||
--- | ||
# Reads a file from a predefined path and writes as well | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: files-exist | ||
spec: | ||
inputs: | ||
resources: | ||
- name: volume1 | ||
type: storage | ||
steps: | ||
- name: read1 | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: | ||
- '-c' | ||
- '[[ stuff == $(cat $(inputs.resources.volume1.path)/stuff1) ]]"' | ||
- name: read3 | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: | ||
- '-c' | ||
- '[[ stuff3 == $(cat $(inputs.resources.volume1.path)/stuff3) ]]"' | ||
--- | ||
# First task writees files to two volumes. The next task ensures these files exist | ||
# then writes a third file to the first volume. The last Task ensures both expected | ||
# files exist on this volume. | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: volume-output-pipeline | ||
spec: | ||
resources: | ||
- name: volume1 | ||
type: storage | ||
- name: volume2 | ||
type: storage | ||
tasks: | ||
- name: first-create-files | ||
taskRef: | ||
name: create-files | ||
resources: | ||
outputs: | ||
- name: volume1 | ||
resource: volume1 | ||
- name: volume2 | ||
resource: volume2 | ||
- name: then-check-and-write | ||
taskRef: | ||
name: files-exist-and-add-new | ||
resources: | ||
inputs: | ||
- name: volume1 | ||
resource: volume1 | ||
from: [first-create-files] | ||
- name: volume2 | ||
resource: volume2 | ||
from: [first-create-files] | ||
outputs: | ||
- name: volume1 | ||
resource: volume1 | ||
- name: then-check | ||
taskRef: | ||
name: files-exist | ||
resources: | ||
inputs: | ||
- name: volume1 | ||
resource: volume1 | ||
from: [first-create-files] | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
name: volume-output-pipeline-run | ||
spec: | ||
pipelineRef: | ||
name: volume-output-pipeline | ||
serviceAccount: 'default' | ||
resources: | ||
- name: volume1 | ||
resourceRef: | ||
name: volume-resource-1 | ||
- name: volume2 | ||
resourceRef: | ||
name: volume-resource-2 |
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
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
Oops, something went wrong.