Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEP-119 - Add TaskRun Template in v1 PipelineRun #5491

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions dev/docs/migrating-v1beta1-to-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ weight: 4000
- [Upgrading `PipelineRun.Timeout` to `PipelineRun.Timeouts`](#upgrading-pipelinerun.timeout-to-pipelinerun.timeouts)
- [Deprecating Resources from Task, TaskRun, Pipeline and PipelineRun](#deprecating-resources-from-task,-taskrun,-pipeline-and-pipelinerun)
- [Replacing `taskRef.bundle` and `pipelineRef.bundle` with Bundle Resolver](#replacing-taskRef.bundle-and-pipelineRef.bundle-with-bundle-resolver)
- [Adding `TaskRunTemplate` in `PipelineRun.Spec`](#adding-taskruntemplate-to-pipelinerun.spec)


This document describes the differences between `v1beta1` Tekton entities and their
Expand All @@ -32,6 +33,8 @@ In Tekton `v1`, the following fields have been changed:
| `taskrun.spec.resources` | removed from `TaskRun` |
| `pipeline.spec.resources` | removed from `Pipeline` |
| `pipelineRun.spec.resources` | removed from `PipelineRun` |
| `pipelineRun.spec.serviceAccountName` | [`pipelineRun.spec.taskRunTemplate.serviceAccountName`](#adding-taskruntemplate-to-pipelinerun.spec) |
| `pipelineRun.spec.podTemplate` | [`pipelineRun.spec.taskRunTemplate.podTemplate`](#adding-taskruntemplate-to-pipelinerun.spec) |

## Deprecating `resources` from Task, TaskRun, Pipeline and PipelineRun
`PipelineResources` are deprecated, and the `resources` fields of Task, TaskRun, Pipeline and PipelineRun has been removed. Please use `Tasks` instead. For more information, see [Replacing PipelineResources](https://github.com/tektoncd/pipeline/blob/main/docs/pipelineresources.md)
Expand Down Expand Up @@ -102,3 +105,37 @@ spec:
```

For more information, see [Remote resolution](https://github.com/tektoncd/community/blob/main/teps/0060-remote-resource-resolution.md).

## Adding TaskRunTemplate to PipelineRun.Spec
`ServiceAccountName` and `PodTemplate` are moved to `TaskRunTemplate` as `TaskRunTemplate.ServiceAccountName` and `TaskRunTemplate.PodTemplate` so that users can specify common configuration in `TaskRunTemplate` which will apply to all the TaskRuns.

```yaml
# Before in v1beta1:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: template-pr
spec:
pipelineRef:
name: clone-test-build
serviceAccountName: build
podTemplate:
securityContext:
fsGroup: 65532
---
# After in v1:
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: template-pr
spec:
pipelineRef:
name: clone-test-build
taskRunSpecTemplate:
serviceAccountName: build
podTemplate:
securityContext:
fsGroup: 65532
```

For more information, see [TEP-119](https://github.com/tektoncd/community/blob/main/teps/0119-add-taskrun-template-in-pipelinerun.md).
82 changes: 52 additions & 30 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,17 +489,6 @@ PipelineSpec
</tr>
<tr>
<td>
<code>serviceAccountName</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
</td>
</tr>
<tr>
<td>
<code>status</code><br/>
<em>
<a href="#tekton.dev/v1.PipelineRunSpecStatus">
Expand Down Expand Up @@ -531,15 +520,16 @@ with Timeouts.pipeline &gt;= Timeouts.tasks + Timeouts.finally</p>
</tr>
<tr>
<td>
<code>podTemplate</code><br/>
<code>taskRunTemplate</code><br/>
<em>
<a href="#tekton.dev/unversioned.Template">
Template
<a href="#tekton.dev/v1.PipelineTaskRunTemplate">
PipelineTaskRunTemplate
</a>
</em>
</td>
<td>
<p>PodTemplate holds pod specific configuration</p>
<em>(Optional)</em>
<p>TaskRunTemplate represent template of taskrun</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -1773,17 +1763,6 @@ PipelineSpec
</tr>
<tr>
<td>
<code>serviceAccountName</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
</td>
</tr>
<tr>
<td>
<code>status</code><br/>
<em>
<a href="#tekton.dev/v1.PipelineRunSpecStatus">
Expand Down Expand Up @@ -1815,15 +1794,16 @@ with Timeouts.pipeline &gt;= Timeouts.tasks + Timeouts.finally</p>
</tr>
<tr>
<td>
<code>podTemplate</code><br/>
<code>taskRunTemplate</code><br/>
<em>
<a href="#tekton.dev/unversioned.Template">
Template
<a href="#tekton.dev/v1.PipelineTaskRunTemplate">
PipelineTaskRunTemplate
</a>
</em>
</td>
<td>
<p>PodTemplate holds pod specific configuration</p>
<em>(Optional)</em>
<p>TaskRunTemplate represent template of taskrun</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -2548,6 +2528,48 @@ Kubernetes core/v1.ResourceRequirements
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.PipelineTaskRunTemplate">PipelineTaskRunTemplate
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1.PipelineRunSpec">PipelineRunSpec</a>)
</p>
<div>
<p>PipelineTaskRunTemplate is used to specify run specifications for all Task in pipelinerun.</p>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>podTemplate</code><br/>
<em>
<a href="#tekton.dev/unversioned.Template">
Template
</a>
</em>
</td>
<td>
<em>(Optional)</em>
</td>
</tr>
<tr>
<td>
<code>serviceAccountName</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1.PipelineWorkspaceDeclaration">PipelineWorkspaceDeclaration
</h3>
<p>
Expand Down
42 changes: 32 additions & 10 deletions pkg/apis/pipeline/v1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/apis/pipeline/v1/pipelinerun_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func (prs *PipelineRunSpec) SetDefaults(ctx context.Context) {
}

defaultSA := cfg.Defaults.DefaultServiceAccount
if prs.ServiceAccountName == "" && defaultSA != "" {
prs.ServiceAccountName = defaultSA
if prs.TaskRunTemplate.ServiceAccountName == "" && defaultSA != "" {
prs.TaskRunTemplate.ServiceAccountName = defaultSA
}

defaultPodTemplate := cfg.Defaults.DefaultPodTemplate
prs.PodTemplate = pod.MergePodTemplateWithDefault(prs.PodTemplate, defaultPodTemplate)
prs.TaskRunTemplate.PodTemplate = pod.MergePodTemplateWithDefault(prs.TaskRunTemplate.PodTemplate, defaultPodTemplate)

if prs.PipelineSpec != nil {
prs.PipelineSpec.SetDefaults(ctx)
Expand Down
Loading