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 PagePod Template Configuration Guide
Next PageHow To

#Regular Cleanup of TaskRun and PipelineRun Resources

#TOC

#Overview

Automatically clean up TaskRun and PipelineRun resources in Tekton using the Pruner feature. The Pruner operates in the background by executing the tkn command to perform resource cleanup.

#Use Cases

  • Regularly clean up TaskRun resources
  • Regularly clean up PipelineRun resources
  • Configure different cleanup strategies based on namespaces

#Prerequisites

  • Tekton Operator component must be installed
  • TektonConfig resource must have been automatically created in the environment

#Steps

#Step 1

Edit the TektonConfig resource

$ kubectl edit tektonconfigs.operator.tekton.dev config

#Step 2

Modify the spec.pruner configuration, as shown below:

apiVersion: operator.tekton.dev/v1alpha1
kind: TektonConfig
metadata:
  name: config
spec:
  pruner:
    # Whether to disable the pruner functionality, defaults to false
    disabled: false
    # Cron expression for scheduled cleanup
    schedule: "0 8 * * *"
    # Optional: Deadline for task start (in seconds)
    startingDeadlineSeconds: 100
    # Types of resources to clean up
    resources:
      - taskrun
      - pipelinerun
    # Number of resources to retain
    keep: 3
    # Apply cleanup strategies separately for each resource type
    prune-per-resource: true
    # Retain resources within the specified time (in minutes)
    # keep-since: 1440
    # Note: only one of keep and keep-since can be used

Key configuration descriptions:

  • disabled: When set to true, disables the pruner functionality (default value: false)
  • schedule: Execution schedule for the cleanup task, using cron expression format
  • startingDeadlineSeconds: Optional configuration for the deadline for task start (in seconds). If the task misses the scheduled time and exceeds this duration, it is counted as failed
  • resources: Supported resource types for cleanup, including taskrun and pipelinerun
  • keep: Maximum number of resources to retain during cleanup
  • keep-since: Retain resources within a specified time (in minutes)
  • prune-per-resource: When set to true (default value is false), applies the keep configuration separately for each resource
    • For example: If there are two Pipelines in namespace ns-1, named pipeline-1 and pipeline-2, the following will be executed:
      tkn pipelinerun delete --pipeline=my-pipeline-1 --keep=3 --namespace=ns-1
      tkn pipelinerun delete --pipeline=my-pipeline-2 --keep=3 --namespace=ns-1
    • Note: When using keep-since, enabling prune-per-resource=true has no practical meaning, as keep-since is based on time constraint for resources, unrelated to the quantity of resources.
NOTE

If disabled: false and schedule is empty, the global pruner task will be disabled. However, if there is an annotation operator.tekton.dev/prune.schedule with a value in the namespace, a pruner task for that namespace will be created.

#Step 3

Configure cleanup strategies via namespace annotations (optional)

By default, the pruner task will use the global configuration (spec.pruner), but users can customize the pruner configuration for specific namespaces through the following annotations. If certain annotations are missing or have invalid values, global configuration values will be used, or the namespace will be skipped.

Supported annotations:

  • operator.tekton.dev/prune.skip: When set to true, skips the pruner task for that namespace
  • operator.tekton.dev/prune.schedule: Sets the cleanup schedule for that namespace
  • operator.tekton.dev/prune.keep: Sets the maximum number of resources to retain
  • operator.tekton.dev/prune.keep-since: Sets the retention period for resources within a specified time (in minutes)
  • operator.tekton.dev/prune.prune-per-resource: Sets whether to apply the cleanup strategy separately for each resource
  • operator.tekton.dev/prune.resources: Sets the types of resources to clean up, which can be taskrun and/or pipelinerun, with multiple values separated by commas
  • operator.tekton.dev/prune.strategy: Sets the cleanup strategy, with optional values of keep or keep-since

Example:

$ kubectl annotate namespace default \
    operator.tekton.dev/prune.schedule="0 1 * * *" \
    operator.tekton.dev/prune.keep="5" \
    operator.tekton.dev/prune.resources="taskrun,pipelinerun"

::: note If no global configuration is set, the following default values will be used:

  • resources: pipelinerun
  • keep: 100 :::

#Results

After configuration is complete, the system will automatically clean up expired TaskRun and PipelineRun resources according to the set schedule.

#Reference

  • Official Documentation: Pruner Configuration