Tekton pipelines — Workspaces
The article contains a simple example — in which we create a pipeline with 2 tasks and a workspace to share files between them.
I am using GCP to run the Kubernetes cluster. In case you don’t have one, to setup a free version, you can follow the steps here
https://github.com/prav10194/tekton-pipeline-example#setting-up-a-cluster
1. Creating tasks yamls
We will start off with an alpine task — the main purpose of that would be to create a file called message.txt in workspace task-ws.
The path of the workspace is available at $(workspace.<name>.path)
Line 6–8 define the workspace name and description. This will be connected to the pipeline code later on.
Creating the second task, which will be again using an alpine image and will print out the content of the file created in initial task.
Access the file by the following command —
cat $(workspaces.task-ws.path)/message.txt
2. Creating pipeline yaml
First step would be to define the workspace name that will be connected to pipelinerun (line 6–7). This name is different than the one used in tasks.
Now for each task in pipeline, define a block (line 12–14), with a name and workspace.
Name will be the same as one we defined in tasks yaml.
Workspace will be the same as line 7.
3. Creating pipelinerun
You need a volume for the workspace. Create a simple volume claim as shown in the yaml.
The workspace name defined here is the same as one in pipeline.
The complete code is available here — https://github.com/prav10194/tekton-pipeline-example/tree/main/workspaces