-
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 support for projected volumes as workspace type
By adding support for projected volumes [1] as workspace type an arbitrary amount of ConfigMaps or Secrets can be passed to a TaskRun/PipelineRun without modifying the actual Task/ClusterTask. This allows to pass data to Tasks/Pipelines in a flexible way. Fixes #5075 [1] https://kubernetes.io/docs/concepts/storage/projected-volumes Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
- Loading branch information
1 parent
201d57b
commit fdf682f
Showing
11 changed files
with
379 additions
and
20 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
133 changes: 133 additions & 0 deletions
133
examples/v1beta1/pipelineruns/alpha/workspaces-projected.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,133 @@ | ||
# In this contrived example two different kinds of workspace volume are used to thread | ||
# data through a pipeline's tasks. | ||
# 1. A projected volume combines a: | ||
# - ConfigMap as source of recipe data. | ||
# - Secret to store a password. | ||
# 2. A PVC is used to share data from one task to the next. | ||
# | ||
# The end result is a pipeline that first checks if the password is correct and, if so, | ||
# copies data out of a recipe store onto a shared volume. The recipe data is then read | ||
# by a subsequent task and printed to screen. | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: sensitive-recipe-storage | ||
data: | ||
brownies: | | ||
1. Heat oven to 325 degrees F | ||
2. Melt 1/2 cup butter w/ 1/2 cup cocoa, stirring smooth. | ||
3. Remove from heat, allow to cool for a few minutes. | ||
4. Transfer to bowl. | ||
5. Whisk in 2 eggs, one at a time. | ||
6. Stir in vanilla. | ||
7. Separately combine 1 cup sugar, 1/4 cup flour, 1 cup chopped | ||
walnuts and pinch of salt | ||
8. Combine mixtures. | ||
9. Bake in greased pan for 30 minutes. Watch carefully for | ||
appropriate level of gooeyness. | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: secret-password | ||
type: Opaque | ||
data: | ||
password: aHVudGVyMg== | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: shared-task-storage | ||
spec: | ||
resources: | ||
requests: | ||
storage: 16Mi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: fetch-secure-data | ||
spec: | ||
workspaces: | ||
- name: secure-store | ||
- name: filedrop | ||
steps: | ||
- name: fetch-and-write | ||
image: ubuntu | ||
script: | | ||
if [ "hunter2" = "$(cat $(workspaces.secure-store.path)/password)" ]; then | ||
cp $(workspaces.secure-store.path)/recipe.txt $(workspaces.filedrop.path) | ||
else | ||
echo "wrong password!" | ||
exit 1 | ||
fi | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: print-data | ||
spec: | ||
workspaces: | ||
- name: storage | ||
readOnly: true | ||
params: | ||
- name: filename | ||
steps: | ||
- name: print-secrets | ||
image: ubuntu | ||
script: cat $(workspaces.storage.path)/$(params.filename) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: fetch-and-print-recipe | ||
spec: | ||
workspaces: | ||
- name: data-store | ||
- name: shared-data | ||
tasks: | ||
- name: fetch-the-recipe | ||
taskRef: | ||
name: fetch-secure-data | ||
workspaces: | ||
- name: secure-store | ||
workspace: data-store | ||
- name: filedrop | ||
workspace: shared-data | ||
- name: print-the-recipe | ||
taskRef: | ||
name: print-data | ||
# Note: this is currently required to ensure order of write / read on PVC is correct. | ||
runAfter: | ||
- fetch-the-recipe | ||
params: | ||
- name: filename | ||
value: recipe.txt | ||
workspaces: | ||
- name: storage | ||
workspace: shared-data | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: recipe-time- | ||
spec: | ||
pipelineRef: | ||
name: fetch-and-print-recipe | ||
workspaces: | ||
- name: data-store | ||
projected: | ||
sources: | ||
- secret: | ||
name: secret-password | ||
- configMap: | ||
name: sensitive-recipe-storage | ||
items: | ||
- key: brownies | ||
path: recipe.txt | ||
- name: shared-data | ||
persistentVolumeClaim: | ||
claimName: shared-task-storage |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.