Free — no signup required

Workspaces: Sharing Data Between Pods

2 min read

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:

  1. Pipeline declares a workspace named source-code (no storage details).
  2. Each Task that needs the code declares it uses the source-code workspace.
  3. PipelineRun binds source-code to a specific PVC named pipeline-pvc.
  4. Task A (git-clone) mounts pipeline-pvc at /workspace/output, clones the repo, and exits.
  5. Task B (build) mounts the same pipeline-pvc at /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.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free