-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 "volume" PipelineResource 🔊 #1417
Closed
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
# This example will be using multiple PVCs and will be run against a regional GKE. | ||
# This means we have to make sure that the PVCs aren't created in different zones, | ||
# and the only way to do this is to create regional PVCs. | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: regional-disk | ||
provisioner: kubernetes.io/gce-pd | ||
parameters: | ||
type: pd-ssd | ||
replication-type: regional-pd | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: volume-resource-1 | ||
spec: | ||
type: storage | ||
params: | ||
- name: type | ||
value: volume | ||
- name: storageClassName | ||
value: regional-disk | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: volume-resource-2 | ||
spec: | ||
type: storage | ||
params: | ||
- name: type | ||
value: volume | ||
- name: path | ||
value: special-folder | ||
- name: storageClassName | ||
value: regional-disk | ||
--- | ||
# Task writes data 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 stuff1 > $(outputs.resources.volume1.path)/stuff1'] | ||
- name: write-new-stuff-2 | ||
image: ubuntu | ||
command: ['bash'] | ||
args: ['-c', 'echo stuff2 > $(outputs.resources.volume2.path)/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: | ||
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' | ||
- '[[ stuff2 == $(cat $(inputs.resources.volume2.path)/stuff2) ]]' | ||
- name: write-new-stuff-3 | ||
image: ubuntu | ||
command: ['bash'] | ||
args: ['-c', 'echo stuff3 > $(outputs.resources.volume1.path)/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' | ||
- '[[ stuff1 == $(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 | ||
# This Task uses the same volume as an input and an output to ensure this works | ||
resource: volume1 | ||
- name: then-check | ||
taskRef: | ||
name: files-exist | ||
resources: | ||
inputs: | ||
- name: volume1 | ||
resource: volume1 | ||
from: [then-check-and-write] | ||
--- | ||
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
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.
I'm getting an error running this from the webhook:
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.
waaaat
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.
shoot, makes one wonder how they ever got this to run XD XD XD
im guessing i added that validation after running it 🤦♀ oh well XD