logo
Alauda DevOps Pipelines Docs
logo
Alauda DevOps Pipelines Docs
Navigation

Overview

Introduction
Architecture
Feature Overview
Lifecycle Policy
Quick Start
Release Notes

Concepts

TektonConfig
TektonPipeline
Install
Upgrade

Configure

Adjusting Optional Configuration Items of Subcomponents
Configuring Resource Quotas for Pipeline Components
Pod Template Configuration Guide
Regular Cleanup of TaskRun and PipelineRun Resources

How To

Deploying tekton-pipelines in a global cluster through TektonConfig

Pipelines

Introduction
Architecture

Concepts

Tasks
TaskRuns
Pipelines
PipelineRuns
StepActions
Resolvers
Workspaces
Pod Templates
Quick Start
permissions

how_to

Adjust Dockerfile for Building Task-Compatible Custom Images

trouble_shooting

Failed to create pod due to config error when using custom images in Tekton

Triggers

Introduction
Architecture

Core Concepts

Core Concepts
EventListener
Trigger
Interceptor
TriggerBinding
TriggerTemplate
Quick Start

How To

Setup EventListener
Use GitLab Event Triggers
Create TriggerTemplate

Troubleshooting

The Pipeline is not automatically triggered
Permission Description

Hub

Introduction
Architecture

Core Concepts

Concepts
Understanding Tekton Hub
Permission Description

Configure

Tekton Hub Configuration
Adding Custom Catalogs

Tutorials

Creating a Custom Catalog
Writing Tasks for Tekton Hub
Writing Pipelines for Tekton Hub

Results

Introduction
Architecture

Concepts

Core Concepts
Tekton Results
Quick Start
permissions

Configure

Database Configuration

Supply Chain Security

Introduction
Architecture

Concepts

Core Concepts
Understanding Tekton Chains
Quick Start

API Reference

Introduction

Kubernetes APIs

Pipelines

Pipeline [tekton.dev/v1]
Task [tekton.dev/v1]
PipelineRun [tekton.dev/v1]
TaskRun [tekton.dev/v1]
ClusterTask [tekton.dev/v1]
Run [tekton.dev/v1]
CustomRun [tekton.dev/v1]
StepAction [tekton.dev/v1]
VerificationPolicy [tekton.dev/v1alpha1]
ResolutionRequest [resolution.tekton.dev/v1beta1]

Triggers

Trigger [triggers.tekton.dev/v1beta1]
TriggerTemplate [triggers.tekton.dev/v1beta1]
EventListener [triggers.tekton.dev/v1beta1]
TriggerBinding [triggers.tekton.dev/v1beta1]
Interceptor [triggers.tekton.dev/v1alpha1]
ClusterTriggerBinding [triggers.tekton.dev/v1beta1]
ClusterInterceptor [triggers.tekton.dev/v1alpha1]

Operator

TektonConfig [operator.tekton.dev/v1alpha1]
TektonInstallerSet [operator.tekton.dev/v1alpha1]
TektonPipeline [operator.tekton.dev/v1alpha1]
TektonTrigger [operator.tekton.dev/v1alpha1]
TektonChain [operator.tekton.dev/v1alpha1]
TektonHub [operator.tekton.dev/v1alpha1]
TektonResult [operator.tekton.dev/v1alpha1]
TektonInstallerSet [operator.tekton.dev/v1alpha1]
OpenShift Pipelines as Code [operator.tekton.dev/v1alpha1]

Advanced APIs

Results

Introduction to API Usage
Results List
Results Details
Result records List
Result logs List
📝 Edit this page on GitHub
Previous PageConcepts
Next PageTaskRuns

#Tasks

A Task is a collection of Steps that execute sequentially on the same node in Kubernetes. Tasks are the fundamental building blocks of a Tekton CI/CD workflow, allowing you to define a series of operations to be performed in order.

#TOC

#Why Tasks are Needed

#Traditional CI/CD Challenges

In traditional CI/CD systems, workflow steps are often tightly coupled with the CI/CD platform itself. This creates several challenges:

  • Portability: Workflows defined in one CI/CD system cannot be easily moved to another
  • Flexibility: Limited ability to customize execution environments for different steps
  • Scalability: Difficulty in scaling individual steps based on resource requirements
  • Reusability: Steps defined for one project are difficult to reuse in other projects

#Tekton's Solution

Tekton Tasks address these challenges by:

  • Container-Based Execution: Each Step runs in its own container, providing isolation and flexibility
  • Kubernetes Native: Tasks run as Kubernetes pods, leveraging Kubernetes' scheduling and scaling capabilities
  • Declarative Definition: Tasks are defined as Kubernetes Custom Resources, making them portable and version-controllable
  • Reusability: Tasks can be shared and reused across projects and teams

#Advantages

  • Isolation: Each Step runs in its own container, preventing conflicts between dependencies
  • Portability: Tasks can run on any Kubernetes cluster without modification
  • Reusability: Tasks can be shared across teams and projects
  • Scalability: Tasks leverage Kubernetes' scheduling and resource management
  • Flexibility: Tasks can be customized with parameters and workspaces
  • Observability: Task execution can be monitored and logged through Kubernetes

#Scenarios

Tasks are useful in various scenarios, including:

  • Build Operations: Compiling source code, running unit tests
  • Deployment Operations: Deploying applications to different environments
  • Validation Operations: Running security scans, code quality checks
  • Infrastructure Operations: Provisioning and configuring infrastructure
  • Data Processing: ETL operations, data validation

#Constraints and Limitations

  • Tasks run on a single Kubernetes node and cannot span multiple nodes
  • All Steps in a Task share the same pod lifecycle
  • Steps in a Task must run sequentially, not in parallel
  • Tasks have limited ability to handle conditional execution (use Pipelines for complex conditions)
  • Task execution time is limited by the Kubernetes pod timeout

#Principles

#Task Execution Model

When a Task is executed through a TaskRun:

  1. Kubernetes creates a Pod for the Task
  2. Each Step in the Task becomes a container in the Pod
  3. Steps run sequentially in the order defined
  4. Tekton injects an entrypoint binary into each Step container
  5. The entrypoint ensures Steps run in the correct order
  6. Workspaces are mounted as volumes in the Pod
  7. Parameters are passed to the Task as environment variables or files
  8. Results are stored and made available to subsequent Tasks

#Step Execution

Steps within a Task execute sequentially. Each Step:

  1. Runs in its own container
  2. Has access to shared workspaces
  3. Can access outputs from previous Steps
  4. Can produce results for subsequent Steps or Tasks

#Configuration Examples

#Basic Task Example

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: build
spec:
  workspaces:
    - name: source
      description: The workspace containing the source code
  steps:
    - name: build
      image: golang
      workingDir: $(workspaces.source.path)
      script: |
        go build -o app .

#Results

Results allow Tasks to produce output values that can be consumed by other Tasks.

#Use Cases

  • Passing build version information
  • Sharing generated artifacts paths
  • Communicating test results
  • Passing deployment URLs

#Principles

Results are:

  • Declared in the Task specification
  • Written to a specific file path by the Task
  • Read by Tekton after Task completion
  • Made available to subsequent Tasks in a Pipeline

#Configuration Example

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: generate-version
spec:
  results:
    - name: version
      description: The generated version number
  steps:
    - name: generate
      image: ubuntu
      script: |
        echo "1.0.$(date +%s)" | tee $(results.version.path)

#Important Parameters

#Workspaces

Workspaces allow Tasks to share data with each other and provide a way to access persistent volumes.

#Use Cases

  • Sharing source code between Tasks
  • Storing build artifacts
  • Sharing configuration files
  • Persisting data between Task runs

#Principles

Workspaces are:

  • Declared in the Task specification
  • Bound to actual storage when creating a TaskRun
  • Mounted at the specified path in each Step container
  • Can be shared between multiple Tasks in a Pipeline

#Configuration Example

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: build
spec:
  workspaces:
    - name: source
      description: The workspace containing the source code
      optional: true
  steps:
    - name: build
      image: golang
      workingDir: $(workspaces.source.path)
      script: |
        go build -o app .

#References

  • Tekton Tasks Official Documentation
  • Tekton Pipelines GitHub Repository
  • Kubernetes Custom Resources