Skip to main content
Workspaces provide flexible storage for your Tasks and Pipelines. This guide covers advanced workspace patterns and techniques.

Overview

Advanced workspace features include:
  • Using subpaths to organize workspace data
  • Isolating workspace access to specific Steps
  • Optional workspaces with conditional logic
  • Sharing workspaces across Pipeline Tasks
  • Dynamic workspace configuration

Workspace Subpaths

Subpaths allow multiple Tasks to use different directories within the same workspace:

Basic Subpath Usage

The Task definitions:
Running the Pipeline:

Parameterized Subpaths

Use parameters to dynamically configure subpaths:
Use parameterized subpaths to organize builds by environment, branch, or other dynamic criteria.

Isolated Workspaces

Limit workspace access to specific Steps within a Task:
By default, workspaces are mounted to all Steps. Use the workspaces field in a Step to override the default mount path or isolate access.

Optional Workspaces

Make workspaces optional and handle their presence conditionally:
Using the Task in a Pipeline:

Workspace Bound Variable

Check if an optional workspace was provided:

Workspace Propagation

Share a Pipeline workspace across multiple Tasks:
Each Task can map the Pipeline workspace to a different workspace name within the Task.

Workspace Types

PersistentVolumeClaim

Use existing PVC:
Create PVC dynamically:

ConfigMap

Secret

EmptyDir

CSI Volumes

Workspace Variables

Access workspace metadata in your Tasks:

Advanced Patterns

Cache Workspace Pattern

Multi-Environment Pattern

Temporary Workspace for Build Artifacts

Best Practices

Use VolumeClaimTemplates for Dynamic Storage

Use volumeClaimTemplate instead of creating PVCs manually. This allows Tekton to manage PVC lifecycle automatically.

Organize with Subpaths

Clean Up After Use

Use Optional Workspaces for Flexibility

Validate Workspace Contents

Use subpaths when:
  • Multiple Tasks need to share a single PVC
  • You want to organize data hierarchically
  • You need to reduce PVC costs
  • Tasks write to different directories
Use separate workspaces when:
  • Data has different lifecycle requirements
  • You need different access modes (ReadOnly vs ReadWrite)
  • Tasks require isolation for security
  • Different storage classes are needed
Common debugging steps:
  1. Check workspace is bound:
  1. List workspace contents:
  1. Check permissions:
  1. Verify PVC: