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
-[Referenced TaskRuns within Embedded PipelineRuns](#referenced-taskruns-within-embedded-pipelineruns)
@@ -1008,6 +1010,60 @@ spec:
1008
1010
1009
1011
If a metadata key is present in different levels, the value that will be used in the `PipelineRun` is determined using this precedence order: `PipelineRun.spec.taskRunSpec.metadata`> `PipelineRun.metadata` > `Pipeline.spec.tasks.taskSpec.metadata`.
1010
1012
1013
+
#### Parameter Substitution in taskRunSpecs
1014
+
1015
+
The `taskRunSpecs` supports parameter substitution in the `podTemplate` fields. This allows you to dynamically configure pod templates based on pipeline parameters, including those from Matrix tasks.
1016
+
1017
+
For example, you can use parameter substitution to configure node selectors based on architecture parameters:
1018
+
1019
+
```yaml
1020
+
spec:
1021
+
taskRunSpecs:
1022
+
- pipelineTaskName: build-task
1023
+
podTemplate:
1024
+
nodeSelector:
1025
+
kubernetes.io/arch: $(params.arch)
1026
+
tolerations:
1027
+
- key: "environment"
1028
+
operator: "Equal"
1029
+
value: "$(params.env)"
1030
+
effect: "NoSchedule"
1031
+
```
1032
+
1033
+
#### Matrix Support with taskRunSpecs
1034
+
1035
+
When using [`Matrix`](matrix.md) to fan out `PipelineTasks`, the `taskRunSpecs` can reference matrix parameters for dynamic pod template configuration. Each matrix combination will create a separate `TaskRun` with the appropriate parameter values substituted in the pod template.
1036
+
1037
+
Here's an example showing how to use `taskRunSpecs` with matrix parameters:
1038
+
1039
+
```yaml
1040
+
spec:
1041
+
taskRunSpecs:
1042
+
- pipelineTaskName: build-and-push-manifest
1043
+
podTemplate:
1044
+
nodeSelector:
1045
+
kubernetes.io/arch: $(params.arch)
1046
+
pipelineSpec:
1047
+
tasks:
1048
+
- name: build-and-push-manifest
1049
+
matrix:
1050
+
params:
1051
+
- name: arch
1052
+
value: ["amd64", "arm64"]
1053
+
taskSpec:
1054
+
params:
1055
+
- name: arch
1056
+
steps:
1057
+
- name: build-and-push
1058
+
image: ubuntu
1059
+
script: |
1060
+
echo "building on $(params.arch)"
1061
+
```
1062
+
1063
+
In this example, the matrix will create two `TaskRuns` - one for `amd64` and one for `arm64`. Each will have its pod scheduled on the appropriate node architecture using the nodeSelector with the substituted parameter value.
1064
+
1065
+
For a complete example, see [`pipelinerun-with-taskrunspecs-matrix-param-substitution.yaml`](../examples/v1/pipelineruns/pipelinerun-with-taskrunspecs-matrix-param-substitution.yaml).
1066
+
1011
1067
### Specifying `Workspaces`
1012
1068
1013
1069
If your `Pipeline` specifies one or more `Workspaces`, you must map those `Workspaces` to
Copy file name to clipboardExpand all lines: docs/podtemplates.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,29 @@ See the following for examples of specifying a Pod template:
23
23
-[Specifying a Pod template for a `TaskRun`](./taskruns.md#specifying-a-pod-template)
24
24
-[Specifying a Pod template for a `PipelineRun`](./pipelineruns.md#specifying-a-pod-template)
25
25
26
+
## Parameter Substitution in Pod Templates
27
+
28
+
When using Pod templates within `PipelineRun`[`taskRunSpecs`](./pipelineruns.md#specifying-taskrunspecs), you can use parameter substitution to dynamically configure Pod template fields based on pipeline parameters. This is particularly useful when working with [`Matrix`](./matrix.md) tasks that fan out with different parameter values.
29
+
30
+
Parameter substitution uses the standard Tekton syntax `$(params.paramName)` and is supported in all Pod template fields that accept string values.
31
+
32
+
Example with parameter substitution:
33
+
```yaml
34
+
taskRunSpecs:
35
+
- pipelineTaskName: build-task
36
+
podTemplate:
37
+
nodeSelector:
38
+
kubernetes.io/arch: $(params.arch)
39
+
environment: $(params.env)
40
+
tolerations:
41
+
- key: "workload-type"
42
+
operator: "Equal"
43
+
value: "$(params.workload)"
44
+
effect: "NoSchedule"
45
+
```
46
+
47
+
When used with Matrix tasks, each matrix combination will create a separate `TaskRun` with the parameter values substituted appropriately in the Pod template. For more information and examples, see [Matrix Support with taskRunSpecs](./pipelineruns.md#matrix-support-with-taskrunspecs).
48
+
26
49
## Supported fields
27
50
28
51
Pod templates support fields listed in the table below.
0 commit comments