1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/op-about-workspace.adoc
Preeti 6acdd699da migration to workspace
Workspace YAML changes 1

Workspace YAML changes 2

minor edit

QE review 1

note on migration from Resources to workspaces

added new section for PVC volumes and front end correction

update PVC link

fix review comments

review comments
2020-09-03 18:18:55 +00:00

98 lines
4.1 KiB
Plaintext

// This module is included in the following assembly:
//
// *openshift_pipelines/creating-applications-with-cicd-pipelines.adoc
[id="about-workspaces_{context}"]
= Workspaces
[NOTE]
====
It is recommended that you use Workspaces instead of PipelineResources in OpenShift Pipelines, as PipelineResources are difficult to debug, limited in scope, and make Tasks less reusable.
====
Workspaces declare shared storage volumes that a Task in a Pipeline needs at runtime. Instead of specifying the actual location of the volumes, Workspaces enable you to declare the filesystem or parts of the filesystem that would be required at runtime. You must provide the specific location details of the volume that is mounted into that Workspace in a TaskRun or a PipelineRun. This separation of volume declaration from runtime storage volumes makes the Tasks reusable, flexible, and independent of the user environment.
With Workspaces, you can:
* Store Task inputs and outputs
* Share data among Tasks
* Use it as a mount point for credentials held in Secrets
* Use it as a mount point for configurations held in ConfigMaps
* Use it as a mount point for common tools shared by an organization
* Create a cache of build artifacts that speed up jobs
You can specify Workspaces in the TaskRun or PipelineRun using:
* A read-only ConfigMaps or Secret
* An existing PersistentVolumeClaim shared with other Tasks
* A PersistentVolumeClaim from a provided VolumeClaimTemplate
* An emptyDir that is discarded when the TaskRun completes
The following example shows a code snippet of the `build-and-deploy` Pipeline, which declares a `shared-workspace` Workspace for the `build-image` and `apply-manifests` Tasks as defined in the Pipeline.
[source,yaml]
----
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: build-and-deploy
spec:
workspaces: <1>
- name: shared-workspace
params:
...
tasks: <2>
- name: build-image
taskRef:
name: buildah
kind: ClusterTask
params:
- name: TLSVERIFY
value: "false"
- name: IMAGE
value: $(params.IMAGE)
workspaces: <3>
- name: source <4>
workspace: shared-workspace <5>
runAfter:
- fetch-repository
- name: apply-manifests
taskRef:
name: apply-manifests
workspaces: <6>
- name: source
workspace: shared-workspace
runAfter:
- build-image
...
----
<1> List of Workspaces shared between the Tasks defined in the Pipeline. A Pipeline can define as many Workspaces as required. In this example, only one Workspace named `shared-workspace` is declared.
<2> Definition of Tasks used in the Pipeline. This snippet defines two Tasks, `build-image` and `apply-manifests`, which share a common Workspace.
<3> List of Workspaces used in the `build-image` Task. A Task definition can include as many Workspaces as it requires. However, it is recommended that a Task uses at most one writable Workspace.
<4> Name that uniquely identifies the Workspace used in the Task. This Task uses one Workspace named `source`.
<5> Name of the Pipeline Workspace used by the Task. Note that the Workspace `source` in turn uses the Pipeline Workspace named `shared-workspace`.
<6> List of Workspaces used in the `apply-manifests` Task. Note that this Task shares the `source` Workspace with the `build-image` Task.
Here is a code snippet of the `build-deploy-api-pipelinerun` PipelineRun, which uses a PersistentVolumeClaim for defining the storage volume for the `shared-workspace` Workspace used in the `build-and-deploy` Pipeline.
[source,yaml]
----
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: build-deploy-api-pipelinerun
spec:
pipelineRef:
name: build-and-deploy
params:
...
workspaces: <1>
- name: shared-workspace <2>
persistentvolumeclaim:
claimName: source-pvc <3>
----
<1> Specifies the list of Pipeline Workspaces for which volume binding will be provided in the PipelineRun.
<2> The name of the Workspace in the Pipeline for which the volume is being provided.
<3> Specifies the name of a predefined PersistentVolumeClaim, which will be attached to the Workspace. In this example, an existing `source-pvc` PersistentVolumeClaim is attached with the `shared-workspace` Workspace.