Skip to main content
Workspaces allow Tasks to share data with each other and declare the volumes they need at runtime.

WorkspaceDeclaration

Declares a workspace required by a Task.
string
required
Name of the workspace.Used to reference the workspace in steps and bind it at runtime.
string
Human-readable description of how the workspace is used.
string
Path where the workspace will be mounted.Defaults to /workspace/<name> if not specified.
boolean
default:false
Whether the workspace is read-only.If true, the volume is mounted read-only.
boolean
default:false
Whether the workspace is optional.If true, the Task can run without this workspace being provided.

WorkspaceBinding

Binds a declared workspace to an actual volume at runtime (in TaskRuns/PipelineRuns).
string
required
Name of the workspace being bound.Must match a workspace declared in the Task or Pipeline.
string
Subdirectory on the volume to use for this binding.Useful when multiple workspaces share the same volume.

Volume Sources

One of the following volume sources must be specified:
EmptyDirVolumeSource
Temporary directory that shares the Task’s lifetime.Data is lost when the Task completes.
PersistentVolumeClaimVolumeSource
Reference to an existing PersistentVolumeClaim.
PersistentVolumeClaim
Template for creating a PVC for each run.The PVC is automatically created and deleted.
ConfigMapVolumeSource
Populate workspace from a ConfigMap.
SecretVolumeSource
Populate workspace from a Secret.
ProjectedVolumeSource
Combine multiple volume sources into one.
CSIVolumeSource
Use a CSI (Container Storage Interface) driver.

PipelineWorkspaceDeclaration

Declares a workspace required by a Pipeline.
string
required
Name of the workspace.
string
Description of how the workspace is used in the Pipeline.
boolean
default:false
Whether the workspace is optional.

WorkspacePipelineTaskBinding

Maps a Pipeline workspace to a Task workspace.
string
required
Name of the workspace as declared by the Task.
string
Name of the workspace declared by the Pipeline.If omitted, assumes the names match.
string
Subdirectory within the Pipeline workspace.

Using Workspaces in Steps

Access workspace paths in steps:

Workspace Isolation

Steps can request exclusive access to workspaces:

Examples

Task with Workspace

TaskRun with emptyDir

TaskRun with PVC

Pipeline Sharing Workspace

PipelineRun with VolumeClaimTemplate

Using SubPath

ConfigMap Workspace

Secret Workspace

Best Practices

  1. Use descriptive names - Clearly indicate workspace purpose
  2. Document workspace usage - Explain what data the workspace contains
  3. Use volumeClaimTemplate for pipelines - Automatically provision storage
  4. Mark optional workspaces - Allow tasks to run without optional data
  5. Use subPath for organization - Share volumes across workspaces
  6. Choose appropriate volume types - Match volume type to data persistence needs
  7. Set readOnly when appropriate - Prevent accidental modifications
  8. Clean up PVCs - Remove volumeClaimTemplate PVCs after use