Tekton Concepts: Difference between revisions
Line 94: | Line 94: | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
===Task | ===Task Volume=== | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-volumes}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-volumes}} | ||
<font color=darkkhaki>TO PROCESS.</font> | <font color=darkkhaki>TO PROCESS.</font> | ||
===Task Step Template=== | ===Task Step Template=== | ||
{{External|https://tekton.dev/docs/pipelines/tasks/#specifying-a-step-template}} | {{External|https://tekton.dev/docs/pipelines/tasks/#specifying-a-step-template}} |
Revision as of 01:55, 28 April 2022
Internal
Overview
Tekton is a cloud-native solution for building CI/CD pipelines. Tekton installs and runs as an extension on your Kubernetes cluster and uses the well-established Kubernetes resource model. Tekton workloads execute inside Kubernetes containers. It has several components: Tekton Pipelines, Tekton CLI and Tekton Catalog. Tekton is part of the CD Foundation, a Linux Foundation project. It is implemented as a set of Kubernetes Custom Resources. Once deployed, Tekton can be accessed via Tekton CLI commands or API calls.
Tekton Domain Model
Task
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's 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.
Task Example
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: hello
spec:
steps:
- name: echo
image: alpine
script: |
#!/bin/sh
echo "Hello World"
Task 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 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: ...
Task Parameters
Specifies execution parameters for this task. TO PROCESS.
Task Resources
PipelineResources are deprecated. This field is valid for alpha only. TO PROCESS.
Task Workspace
Specifies paths to volumes required by the this task.
TO PROCESS.
Task Results
Specifies the names under which this task writes execution results.
TO PROCESS.
Task Volume
TO PROCESS.
Task Step Template
TO PROCESS.
Task Sidecar
TO PROCESS.
Task Operations
ClusterTask
A task is available in a certain namespace, while a ClusterTask is available across the entire cluster.
Step
A step is an operation in a CI/CD workflow. An example is Java compilation or execution of unit tests. Each step is performed within a container image provided when the step is defined. A step processes a set of inputs and produces a set of outputs. Steps do not exist in isolation, they are part of tasks, and they are executed as running containers with the task's pod. As such, a task's steps may share a volume, that allows them to exchange data. These containers are referred to as step containers.
TaskRun
A task run (or taskRun) instantiates a specific task to execute on a particular set of inputs and produce a particular set of outputs, within specific conditions (for example, build flags). A task run connects resources with tasks. A task run can be created individually via CLI, by a pipeline run, as part of a pipeline, or by a Tekton components such as Tekton Triggers. The task run is implemented as a Kubernetes custom resource.
Simple taskrun example:
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: hello-task-run
spec:
taskRef:
name: hello
TaskRun Operations
Pipeline
A pipeline defines a series of ordered tasks. Just like steps, a task in a pipeline can use as input the output of a previously executed task. Tekton collects all the tasks, and based on the dependency relationships declared in definition of the pipeline, it orders the tasks in a DAG, and executes the graph in sequence. That results in the materialization of a number of task pods. The pipeline comes up with additional features, such as the capability to fan-out task execution, retry task execution or verify conditions that tasks must meet before proceeding. The pipeline is implemented as a Kubernetes custom resource.
Simple pipeline example:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task1
spec:
steps:
- name: echo
image: alpine
script: |
#!/bin/sh
echo "this is Task 1 output"
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task2
spec:
steps:
- name: echo
image: alpine
script: |
#!/bin/sh
echo "this is Task 2 output"
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: simple-pipeline
spec:
tasks:
- name: task1
taskRef:
name: task1
- name: task2
runAfter:
- task1
taskRef:
name: task2
PipelineRun
A pipeline run (or pipelineRun) instantiates a specific pipeline to execute on a particular set of inputs and produce a particular set of outputs. A pipeline run connects resources with pipelines. A pipeline run can be created via CLI, or by a Tekton components such as Tekton Triggers. The pipeline run is implemented as a Kubernetes custom resource.
Simple pipelinerun example:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: simple-pipeline-run
spec:
pipelineRef:
name: simple-pipeline
PipelineRun Operations
PipelineResource
Deprecated. Defines locations for inputs ingested and outputs produced by the steps in tasks. Also see Task Resources.
Trigger
Implemented as part of the Tekton Triggers component.
Resource
Resources are used to share data between steps and tasks, and depending on which direction they are looked at, the can be input or output resources. Resources are connected to tasks and pipelines by taskRuns and pipelineRuns, respectively. A run must include the actual addresses of resources, such as the URLs of repositories, its task or pipeline needs.
Example of resources:
- git repository
- a pull request
- a container image
- a Kubernetes cluster
- storage: an object, a directory, etc.
- a CloudEvent
Input Resource
The input is defined relative to a step. Examples of input resources are: git repository.
Output Resource
The output is defined relative to a step. Examples of output resources: container image.
Result
Tekton Results aims to help users logically group CI/CD workload history and separate out long term result storage away from the Pipeline controller.
Run
Instantiates a Custom Task for execution when specific inputs.
Tekton Runtime Model
Tekton Pipelines tracks the state of a pipeline using Kubernetes annotations, which are projected inside each step container in the form of files with the Kubernetes Downward API. The step container entrypoint binary watches these projected files and will only start the command the step is supposed to execute only if a specific annotation appears as file.
In addition, Tekton Pipelines schedules some containers to run automatically before and after the step containers to support built-in features such as the retrieval of input resources and the uploading the outputs to wherever they are supposed to go.
Tekton Components
Tekton Pipelines
Tekton Pipelines is the component that implements the core functionality of Tekton and sets the foundation for other components. It is implemented as a set of Kubernetes Custom Resources.
Tekton Pipeline Runtime
Tekton Pipelines Controller
Tekton Pipelines Webhook
Tekton Pipeline Operations
Tekton CLI
Tekton CLI provides the command interface called tkn
.
Tekton CLI Operations
Tekton API
Tekton APIs are currently available for Pipelines and Triggers allow you to programmatically interact with the Tekton components.
Tekton Catalog
Tekton Catalog is a repository of community-contributed Tekton building blocks.
Tekton Hub
Tekton Hub is a web GUI to access Tekton Catalog.
Tekton Triggers
Tekton Triggers provide triggers, which allow instantiating pipelines based on events (a PR merge, etc.)
Tekton Dashboard
Tekton Dashboard is the web GUI that displays information about pipeline execution.
Tekton Operator
Tekton Operator is the implementation of the Kubernetes Operator pattern that assists with the operation of the Tekton projects.
Building Block
Tekton documentation refers to "building blocks". Those are ...