Tekton Task: Difference between revisions
No edit summary |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
* [[Tekton_Concepts#Task|Tekton Concepts]] | * [[Tekton_Concepts#Task|Tekton Concepts]] | ||
=Overview= | =Overview= | ||
A '''task''' defines a series of ordered [[Tekton_Step#Overview|steps]], which are executed in order in which they are declared. The output of a step can be used as the input of the next step. Each task executes in its own Kubernetes pod, where individual | A '''task''' defines a series of ordered [[Tekton_Step#Overview|steps]], which are executed in order in which they are declared. The output of a step can be used as the input of the next step. Each task executes in its own Kubernetes pod, where individual steps are executed as pod containers, so by default, tasks within a [[Tekton_Pipeline#Overview|pipeline]] do not share data. To make tasks share data, they must be explicitly configured to make their outputs available to the next task, and to ingest the outputs of a previously executed task, as inputs. A task can be executed on its own, or part of a pipeline. The task is implemented as a Kubernetes custom resource. | ||
=Example= | =Example= | ||
Line 21: | Line 21: | ||
echo "Hello World" | echo "Hello World" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= | =Manifest= | ||
<font size=-1> | <font size=-1> | ||
apiVersion: tekton.dev/v1beta1 <font color=teal># required field</font> | apiVersion: tekton.dev/v1beta1 <font color=teal># required field</font> | ||
Line 29: | Line 29: | ||
spec: <font color=teal> # required field</font> | spec: <font color=teal> # required field</font> | ||
description: 'this is an optional description' | description: 'this is an optional description' | ||
[[# | <span id='_params'></span>[[#Parameters|params]]: | ||
- name: <font color=indigo><''some-array-parameter''></font> | - name: <font color=indigo><''some-array-parameter''></font> | ||
type: array | type: array | ||
- name: <font color=indigo><''some-string-parameter''></font> | - name: <font color=indigo><''some-string-parameter''></font> | ||
type: string | type: string | ||
[[# | [[#Results|results]]: | ||
- name: <font color=indigo><''some-name''></font> | - name: <font color=indigo><''some-name''></font> | ||
description: '...' | description: '...' | ||
[[# | [[#Step_Template|stepTemplate]]: | ||
env: | env: | ||
- name: '...' | - name: '...' | ||
Line 54: | Line 54: | ||
- name: docker-socket-example | - name: docker-socket-example | ||
mountPath: /var/run/docker.sock | mountPath: /var/run/docker.sock | ||
[[# | [[#Workspace|workspaces]]: | ||
- name: <font color=indigo>''workspace-name''</font> | - name: <font color=indigo>''workspace-name''</font> | ||
description: | description: | ||
mountPath: <font color=indigo>''path-relative-to-root''</font> | mountPath: <font color=indigo>''path-relative-to-root''</font> | ||
[[# | [[#Volume|volumes]]: | ||
- name: <font color=indigo>''volume-name''</font> | - name: <font color=indigo>''volume-name''</font> | ||
emptyDir: {} | emptyDir: {} | ||
[[# | [[#Sidecar|sidecars]]: | ||
- image: <font color=indigo>''some-image''</font> | - image: <font color=indigo>''some-image''</font> | ||
name: <font color=indigo>''some-name''</font> | name: <font color=indigo>''some-name''</font> | ||
Line 69: | Line 69: | ||
- name: <font color=indigo>''some-name''</font> | - name: <font color=indigo>''some-name''</font> | ||
mountPath: <font color=indigo>''some-mount-path''</font> | mountPath: <font color=indigo>''some-mount-path''</font> | ||
<font color=darkgray>[[# | <font color=darkgray>[[#Resources|resources]]: # deprecated | ||
inputs: | inputs: | ||
- name: ... | - name: ... | ||
Line 78: | Line 78: | ||
</font> | </font> | ||
= | =Parameters= | ||
{{ | {{Internal|Tekton Parameters#Task_Parameters|Tekton Parameters}} | ||
=Resources= | |||
= | |||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-resources}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-resources}} | ||
[[#PipelineResource|PipelineResources]] are deprecated. This field is valid for alpha only. | [[#PipelineResource|PipelineResources]] are deprecated. This field is valid for alpha only. | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
= | =Workspace= | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-workspaces}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-workspaces}} | ||
Specifies paths to volumes required by the this task. | Specifies paths to volumes required by the this task. | ||
Line 96: | Line 91: | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
= | =Results= | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#emitting-results}} | {{External|https://tekton.dev/docs/pipelines/tasks/#emitting-results}} | ||
Specifies the names under which this task writes execution results. A task is able to emit string results that can be viewed by users and passed to other tasks in the pipeline. These results have a wide variety of potential uses | Specifies the names under which this task writes execution results. A task is able to emit string results that can be viewed by users and passed to other tasks in the pipeline. These results have a wide variety of potential uses | ||
Line 102: | Line 97: | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
= | =Volume= | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-volumes}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-volumes}} | ||
Specifies one or more volumes that will be available to the [[Tekton_Step#Overview|steps]] in this task. | Specifies one or more volumes that will be available to the [[Tekton_Step#Overview|steps]] in this task. | ||
Line 108: | Line 103: | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
= | =Step Template= | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-a-step-template}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-a-step-template}} | ||
Specifies a container step definition to use as the basis for all [[Tekton_Step#Overview|steps]] in this task. | Specifies a container step definition to use as the basis for all [[Tekton_Step#Overview|steps]] in this task. | ||
Line 114: | Line 109: | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
= | =Sidecar= | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-sidecars}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-sidecars}} | ||
Specifies sidecar containers to run alongside the [[Tekton_Step#Overview|steps]] in the task. | Specifies sidecar containers to run alongside the [[Tekton_Step#Overview|steps]] in the task. | ||
Line 120: | Line 115: | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
=Task Operations= | |||
* [[Tekton_Operations#List_Tasks|List tasks]] | * [[Tekton_Operations#List_Tasks|List tasks]] |
Latest revision as of 23:33, 28 April 2022
External
- https://tekton.dev/docs/pipelines/tasks/
- https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md
Internal
Overview
A task defines a series of ordered steps, which are executed in order in which they are declared. The output of a step can be used as the input of the next step. Each task executes in its own Kubernetes pod, where individual steps are executed as pod containers, so by default, tasks within a pipeline do not share data. To make tasks share data, they must be explicitly configured to make their outputs available to the next task, and to ingest the outputs of a previously executed task, as inputs. A task can be executed on its own, or part of a pipeline. The task is implemented as a Kubernetes custom resource.
Example
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: hello
spec:
steps:
- name: echo
image: alpine
script: |
#!/bin/sh
echo "Hello World"
Manifest
apiVersion: tekton.dev/v1beta1 # required field kind: Task # required field metadata: # required field name: <task-name> # required field spec: # required field description: 'this is an optional description' params: - name: <some-array-parameter> type: array - name: <some-string-parameter> type: string results: - name: <some-name> description: '...' stepTemplate: env: - name: '...' value: '...' steps: # required field - name: step-1 image: ubuntu args: ["ubuntu-build-example", "SECRETS-example.md"] - image: gcr.io/example-builders/build-example command: ["echo"] args: ["$(params.pathToDockerFile)"] - name: step-3 image: gcr.io/example-builders/push-example args: ["push", "$(resources.outputs.builtImage.url)"] volumeMounts: - name: docker-socket-example mountPath: /var/run/docker.sock workspaces: - name: workspace-name description: mountPath: path-relative-to-root volumes: - name: volume-name emptyDir: {} sidecars: - image: some-image name: some-name securityContext: privileged: true volumeMounts: - name: some-name mountPath: some-mount-path resources: # deprecated inputs: - name: ... type: ... outputs: - name: ... type: ...
Parameters
Resources
PipelineResources are deprecated. This field is valid for alpha only. TO PROCESS.
Workspace
Specifies paths to volumes required by the this task.
TO PROCESS.
Results
Specifies the names under which this task writes execution results. A task is able to emit string results that can be viewed by users and passed to other tasks in the pipeline. These results have a wide variety of potential uses
TO PROCESS.
Volume
Specifies one or more volumes that will be available to the steps in this task.
TO PROCESS.
Step Template
Specifies a container step definition to use as the basis for all steps in this task.
TO PROCESS.
Sidecar
Specifies sidecar containers to run alongside the steps in the task.
TO PROCESS.