-
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.
Add workspace types for Task and TaskRun with validation
This allows users to use Volumes with Tasks such that: - The actual volumes to use (or subdirectories on those volumes) are provided at runtime, not at Task authoring time - At Task authoring time you can declare that you expect a volume to be provided and control what path that volume should end up at - Validation will be provided that the volumes (workspaces) are actually provided at runtime Before this change, there were two ways to use Volumes with Tasks: - VolumeMounts were explicitly declared at the level of a step - Volumes were declared in Tasks, meaning the Task author controlled the name of the volume being used and it wasn't possible at runtime to use a subdir of the volume - Or the Volume could be provided via the podTemplate, if the user realized this was possible None of this was validated and could cause unexpected and hard to diagnose errors at runtime. It's possible folks might be specifying volumes already in the Task or via the stepTemplate that might collide with the names we are using for the workspaces; instead of validating this and making the Task author change these, we can instead randomize them! We have also limited (at least initially) the types of volume source being supported instead of expanding to all volume sources, tho we can expand it later if we want to and if users need it. This would reduce the API surface that a Tekton compliant system would need to conform to (once we actually define what conformance means!). Part of #1438 In future commits we will add support for workspaces to Pipelines and PipelineRuns as well; for now if a user tries to use a Pipeline with a Task that requires a Workspace, it will fail at runtime because it is not (yet) possible for the Pipeline and PipelineRun to provide workspaces. Co-authored-by: Scott <sbws@google.com>
- Loading branch information
1 parent
501fd2d
commit c55d311
Showing
33 changed files
with
1,668 additions
and
51 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,68 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: my-pvc | ||
spec: | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: TaskRun | ||
metadata: | ||
generateName: custom-volume- | ||
spec: | ||
workspaces: | ||
- name: custom | ||
persistentVolumeClaim: | ||
claimName: my-pvc | ||
subPath: my-subdir | ||
- name: custom2 | ||
persistentVolumeClaim: | ||
claimName: my-pvc | ||
- name: custom3 | ||
emptyDir: {} | ||
subPath: testing | ||
taskSpec: | ||
steps: | ||
- name: write | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
set -xe | ||
echo $(workspaces.custom.volume) > $(workspaces.custom.path)/foo | ||
- name: read | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
set -xe | ||
cat $(workspaces.custom.path)/foo | grep $(workspaces.custom.volume) | ||
- name: write2 | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
set -xe | ||
echo $(workspaces.custom2.path) > $(workspaces.custom2.path)/foo | ||
- name: read2 | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
cat $(workspaces.custom2.path)/foo | grep $(workspaces.custom2.path) | ||
- name: write3 | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
echo $(workspaces.custom3.path) > $(workspaces.custom3.path)/foo | ||
- name: read3 | ||
image: ubuntu | ||
script: | | ||
#!/usr/bin/env bash | ||
cat $(workspaces.custom3.path)/foo | grep $(workspaces.custom3.path) | ||
workspaces: | ||
- name: custom | ||
- name: custom2 | ||
mountPath: /foo/bar/baz | ||
- name: custom3 |
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,22 @@ | ||
/* | ||
Copyright 2019 The Tekton Authors | ||
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. | ||
*/ | ||
|
||
package pipeline | ||
|
||
const ( | ||
// WorkspaceDir is the root directory used for PipelineResources and (by default) Workspaces | ||
WorkspaceDir = "/workspace" | ||
) |
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.