You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document how PVC access modes affect pipeline execution
The access mode configured for a PVC that is used as a workspace volume source
may affect how a pipeline is executed, this is not well documented. This commit
intend to improve the documentation about this and also provide an example
on how to run parallel tasks when using PVC with ReadWriteOnce access mode.
- Document how access mode affect task ordering in pipeline under "Specifying Workspace order in a Pipeline"
- Provide a full pipeline example of how to use parallel tasks when using a PVC with access mode ReadWriteOnce
- We we did provide a "PipelineRun example" under "Example PipelineRun definitions using Workspaces".
This commit provide a full PipelineRun example using a workspace. Instead of providing examples of
different volume sources here, examples on how to use different VolumeSources is moved to
"Specifying VolumeSources in Workspaces"
- The VolumeSources persistentVolumeClaim and volumeClaimTemplate both is a PVC, and PVCs has its own
peculiarities, e.g. access mode that we document. Both PVC volume sources is moved to a section
so we can document the common peculiarities in a single place
- Add the workspace variable introduced in tektoncd#2506
`ReadWriteMany`or `ReadOnlyMany` but you must ensure that those are available for your storage class.
258
+
When using `PersistentVolumeClaims` with access mode `ReadWriteOnce` for parallel `Tasks`, you can configure a
259
+
workspace with it's own `PersistentVolumeClaim` for each parallel `Task`. See a full example of a
260
+
[Pipeline with parallel tasks using PersistentVolumeClaims](../examples/v1beta1/pipelineruns/pipelinerun-with-parallel-tasks-using-pvc.yaml).
261
+
262
+
Use the `runAfter` field in your `Pipeline` definition to define when a `Task` should be executed. For more
255
263
information, see the [`runAfter` documentation](pipelines.md#runAfter).
256
264
265
+
**Warning:** You *must* ensure that this order is compatible with the configured access modes for your `PersistentVolumeClaim`.
266
+
Parallel `Tasks` using the same `PersistentVolumeClaim` with access mode `ReadWriteOnce`, may execute on
267
+
different nodes and be forced to execute sequentially which may cause `Tasks` to time out.
268
+
257
269
#### Specifying `Workspaces` in `PipelineRuns`
258
270
259
271
For a `PipelineRun` to execute a `Pipeline` that includes one or more `Workspaces`, it needs to
260
-
bind the `Workspace` names to physical volumes using its own `workspaces` field. Each entry in
272
+
bind the `Workspace` names to volumes using its own `workspaces` field. Each entry in
261
273
this list must correspond to a `Workspace` declaration in the `Pipeline`. Each entry in the
262
274
`workspaces` list must specify the following:
263
275
@@ -269,12 +281,52 @@ The entry must also include one `VolumeSource`. See [Using `VolumeSources` with
269
281
270
282
**Note:** If the `Workspaces` specified by a `Pipeline` are not provided at runtime by a `PipelineRun`, that `PipelineRun` will fail.
271
283
272
-
#### Example `PipelineRun` definitions using `Workspaces`
284
+
#### Example `PipelineRun` definition using `Workspaces`
285
+
286
+
In the example below, a `volumeClaimTemplate` is provided for how a `PersistentVolumeClaim` should be created for a workspace named
287
+
`myworkspace`declared in a `Pipeline`. When using `volumeClaimTemplate` a new `PersistentVolumeClaim` is created for
288
+
each `PipelineRun` and it allows the user to specify e.g. size and StorageClass for the volume.
289
+
290
+
```yaml
291
+
apiVersion: tekton.dev/v1beta1
292
+
kind: PipelineRun
293
+
metadata:
294
+
generateName: pr-
295
+
spec:
296
+
pipelineRef:
297
+
name: example-pipeline
298
+
workspaces:
299
+
- name: myworkspace # this workspace name must be declared in the Pipeline
300
+
volumeClaimTemplate:
301
+
spec:
302
+
accessModes:
303
+
- ReadWriteOnce # access mode may affect how you can use this volume in parallel tasks
304
+
resources:
305
+
requests:
306
+
storage: 1Gi
307
+
```
308
+
309
+
For examples of using other types of volume sources, see [Specifying `VolumeSources` in `Workspaces`](#specifying-volumesources-in-workspaces).
310
+
For a more in-depth example, see the [`Workspaces` in `PipelineRun`](../examples/v1beta1/pipelineruns/workspaces.yaml) YAML sample.
311
+
312
+
### Specifying `VolumeSources` in `Workspaces`
313
+
314
+
You can only use a single type of `VolumeSource` per `Workspace` entry. The configuration
315
+
options differ for each type. `Workspaces` support the following fields:
316
+
317
+
#### Using `PersistentVolumeClaims` as `VolumeSource`
318
+
319
+
`PersistentVolumeClaim`volumes are a good choice for sharing data among `Tasks` within a `Pipeline`.
320
+
Beware that the [access mode](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes)
321
+
configured for the `PersinstentVolumeClaim` effects how you can use the volume for parallel `Tasks` in a `Pipeline`. See
322
+
[Specifying `workspace` order in a `Pipeline`](#specifying-workspace-order-in-a-pipeline) for more information about this.
323
+
There are two ways of using `PersistentVolumeClaims` as a `VolumeSource`.
273
324
274
-
The examples below illustrate how to specify `Workspaces` in your `PipelineRuns`. For a more in-depth example, see the
275
-
[`Workspaces` in `PipelineRun`](../examples/v1beta1/pipelineruns/workspaces.yaml) YAML sample.
325
+
##### `volumeClaimTemplate`
276
326
277
-
In the example below, a template is provided for how a `PersistentVolumeClaim` should be created for a workspace named `myworkspace` declared in a `Pipeline`. When using `volumeClaimTemplate` a new `PersistentVolumeClaim` is created for each `PipelineRun` and it allows the user to specify e.g. size and StorageClass for the volume.
327
+
The `volumeClaimTemplate` is a template of a [`PersistentVolumeClaim` volume](https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim),
328
+
created for each `PipelineRun` or `TaskRun`. When the volume is created from a template in a `PipelineRun` or `TaskRun`
329
+
it will be deleted when the `PipelineRun` or `TaskRun` is deleted.
278
330
279
331
```yaml
280
332
workspaces:
@@ -288,8 +340,9 @@ workspaces:
288
340
storage: 1Gi
289
341
```
290
342
291
-
In the example below, an existing `PersistentVolumeClaim` named `mypvc` is used for a `Workspace`
292
-
named `myworkspace` declared in a `Pipeline`. It exposes only the subdirectory `my-subdir` from that `PersistentVolumeClaim`:
343
+
##### `persistentVolumeClaim`
344
+
345
+
The `persistentVolumeClaim` field references an *existing* [`persistentVolumeClaim` volume](https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim). The example exposes only the subdirectory `my-subdir` from that `PersistentVolumeClaim`
293
346
294
347
```yaml
295
348
workspaces:
@@ -299,49 +352,21 @@ workspaces:
299
352
subPath: my-subdir
300
353
```
301
354
302
-
In the example below, a `ConfigMap` named `my-configmap` is used for a `Workspace`
303
-
named `myworkspace` declared in a `Pipeline`:
355
+
#### Using other types of `VolumeSources`
304
356
305
-
```yaml
306
-
workspaces:
307
-
- name: myworkspace
308
-
configmap:
309
-
name: my-configmap
310
-
```
357
+
##### `emptyDir`
311
358
312
-
In the example below, a `Secret` named `my-secret` is used for a `Workspace`
313
-
named `myworkspace` declared in a `Pipeline`:
359
+
The `emptyDir` field references an [`emptyDir` volume](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) which holds
360
+
a temporary directory that only lives as long as the `TaskRun` that invokes it. `emptyDir` volumes are **not** suitable for sharing data among `Tasks` within a `Pipeline`.
361
+
However, they work well for single `TaskRuns` where the data stored in the `emptyDir` needs to be shared among the `Steps` of the `Task` and discarded after execution.
314
362
315
363
```yaml
316
364
workspaces:
317
365
- name: myworkspace
318
-
secret:
319
-
secretName: my-secret
366
+
emptyDir: {}
320
367
```
321
368
322
-
### Specifying `VolumeSources` in `Workspaces`
323
-
324
-
You can only use a single type of `VolumeSource` per `Workspace` entry. The configuration
325
-
options differ for each type. `Workspaces` support the following fields:
326
-
327
-
#### `emptyDir`
328
-
329
-
The `emptyDir` field references an [`emptyDir` volume](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) which holds
330
-
a temporary directory that only lives as long as the `TaskRun` that invokes it. `emptyDir` volumes are **not** suitable for sharing data among `Tasks` within a `Pipeline`.
331
-
However, they work well for single `TaskRuns` where the data stored in the `emptyDir` needs to be shared among the `Steps` of the `Task` and discarded after execution.
332
-
333
-
#### `persistentVolumeClaim`
334
-
335
-
The `persistentVolumeClaim` field references an existing [`persistentVolumeClaim` volume](https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim).
336
-
`PersistentVolumeClaim`volumes are a good choice for sharing data among `Tasks` within a `Pipeline`.
337
-
338
-
#### `volumeClaimTemplate`
339
-
340
-
The `volumeClaimTemplate` is a template of a [`persistentVolumeClaim` volume](https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim), created for each `PipelineRun` or `TaskRun`.
341
-
When the volume is created from a template in a `PipelineRun` or `TaskRun` it will be deleted when the `PipelineRun` or `TaskRun` is deleted.
342
-
`volumeClaimTemplate`volumes are a good choice for sharing data among `Tasks` within a `Pipeline` when the volume is only used during a `PipelineRun` or `TaskRun`. See [`Workspaces` from a volumeClaimTemplate in a `PipelineRun`](../examples/v1beta1/pipelineruns/workspace-from-volumeclaimtemplate.yaml) for a complete example.
343
-
344
-
#### `configMap`
369
+
##### `configMap`
345
370
346
371
The `configMap` field references a [`configMap` volume](https://kubernetes.io/docs/concepts/storage/volumes/#configmap).
347
372
Using a `configMap` as a `Workspace` has the following limitations:
@@ -350,7 +375,14 @@ Using a `configMap` as a `Workspace` has the following limitations:
350
375
- The `configMap` you want to use as a `Workspace` must exist prior to submitting the `TaskRun`.
351
376
- `configMaps`are [size-limited to 1MB](https://github.com/kubernetes/kubernetes/blob/f16bfb069a22241a5501f6fe530f5d4e2a82cf0e/pkg/apis/core/validation/validation.go#L5042).
352
377
353
-
#### `secret`
378
+
```yaml
379
+
workspaces:
380
+
- name: myworkspace
381
+
configmap:
382
+
name: my-configmap
383
+
```
384
+
385
+
##### `secret`
354
386
355
387
The `secret` field references a [`secret` volume](https://kubernetes.io/docs/concepts/storage/volumes/#secret).
356
388
Using a `secret` volume has the following limitations:
@@ -359,6 +391,13 @@ Using a `secret` volume has the following limitations:
359
391
- The `secret` you want to use as a `Workspace` must exist prior to submitting the `TaskRun`.
360
392
- `secret`are [size-limited to 1MB](https://github.com/kubernetes/kubernetes/blob/f16bfb069a22241a5501f6fe530f5d4e2a82cf0e/pkg/apis/core/validation/validation.go#L5042).
361
393
394
+
```yaml
395
+
workspaces:
396
+
- name: myworkspace
397
+
secret:
398
+
secretName: my-secret
399
+
```
400
+
362
401
If you need support for a `VolumeSource` type not listed above, [open an issue](https://github.com/tektoncd/pipeline/issues) or
363
402
a [pull request](https://github.com/tektoncd/pipeline/blob/master/CONTRIBUTING.md).
0 commit comments