The Problem
Since every Task in a Pipeline runs in its own Pod (potentially on a different Kubernetes node), they cannot share an in-memory filesystem or a local /tmp directory. If your git-clone Task writes source code to disk, your build Task on a different Pod cannot see it — unless you use shared storage.
The Solution: Workspaces
Tekton Workspaces are named storage slots that Tasks declare they need. The actual storage backing is provided at runtime by the PipelineRun. This separation of concerns is deliberate: the Task definition stays portable and storage-agnostic, while the PipelineRun wires in the real storage for the environment.
The most common backing type is a PersistentVolumeClaim (PVC), which is a Kubernetes abstraction for durable block storage (backed by EBS on AWS, Persistent Disk on GCP, etc.).
The flow works like this:
- Pipeline declares a workspace named
source-code(no storage details). - Each Task that needs the code declares it uses the
source-codeworkspace. - PipelineRun binds
source-codeto a specific PVC namedpipeline-pvc. - Task A (git-clone) mounts
pipeline-pvcat/workspace/output, clones the repo, and exits. - Task B (build) mounts the same
pipeline-pvcat/workspace/source, finds the cloned code, and builds it.
Other workspace backing types include:
| Type | Use Case |
|---|---|
persistentVolumeClaim |
Sharing large files (source code, build artifacts) across Tasks |
emptyDir |
Temporary scratch space within a single TaskRun (not shared across Tasks) |
configMap |
Injecting configuration files into a Task |
secret |
Injecting credentials (SSH keys, tokens) into a Task |
Senior insight: PVC-backed workspaces introduce a subtle performance consideration. If your pipeline runs Tasks in parallel and both need to write to the same PVC, you need a ReadWriteMany (RWX) access mode — which not all storage classes support. EBS volumes, for example, only support ReadWriteOnce (RWO). A common pattern is to use RWO for sequential pipelines and switch to an NFS-backed or CephFS storage class for parallel write scenarios.