Tekton Task: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 80: Line 80:
=Parameters=
=Parameters=
{{Internal|Tekton Parameters#Task_Parameters|Tekton Parameters}}
{{Internal|Tekton Parameters#Task_Parameters|Tekton Parameters}}
===Resources===
=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.

Revision as of 21:56, 28 April 2022

External

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

Tekton Parameters

Resources

https://tekton.dev/docs/pipelines/tasks/#specifying-resources

PipelineResources are deprecated. This field is valid for alpha only. TO PROCESS.

Task Workspace

https://tekton.dev/docs/pipelines/tasks/#specifying-workspaces

Specifies paths to volumes required by the this task.

TO PROCESS.

Task Results

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

TO PROCESS.

Task Volume

https://tekton.dev/docs/pipelines/tasks/#specifying-volumes

Specifies one or more volumes that will be available to the steps in this task.

TO PROCESS.

Task Step Template

https://tekton.dev/docs/pipelines/tasks/#specifying-a-step-template

Specifies a container step definition to use as the basis for all steps in this task.

TO PROCESS.

Task Sidecar

https://tekton.dev/docs/pipelines/tasks/#specifying-sidecars

Specifies sidecar containers to run alongside the steps in the task.

TO PROCESS.

Task Operations