Pruner Configuration
TOC
Overview
Tekton Pruner manages the lifecycle of Tekton resources by automatically cleaning up completed PipelineRuns and TaskRuns based on configurable time-based (TTL) and history-based policies.
Configuration
Pruner configuration is stored in a ConfigMap with app.kubernetes.io/part-of: tekton-pruner and pruner.tekton.dev/config-type: <global|namespace> labels. You can modify this ConfigMap to change the behavior of Pruner.
By default, Tekton Pruner is disabled by TektonConfig resource. You can modify the TektonConfig resource to configure Pruner.
Essentially, Tekton Operator will synchronize the Pruner configuration from the TektonConfig resource to the TektonPruner resource, and finally reflect in the ConfigMap.
If you deploy Pruner through TektonConfig, you must configure Pruner through TektonConfig.
If you only modify the configuration in the ConfigMap, and it is not synchronized to the TektonPruner resource, the configuration may be lost.
When the configuration in TektonConfig changes, or some other reason triggers a reconciliation, the configuration in the ConfigMap will be overwritten.
Below is a simple demonstration of the different ways to configure Pruner.
Configuration in ConfigMap
CRITICAL: All pruner ConfigMaps MUST have these labels:
These labels enable the pruner webhook to validate ConfigMaps and controllers to process them correctly.
The following is an example of the Tekton Pruner ConfigMap:
Explanation of YAML fields:
The enforcedConfigLevel determines the configuration hierarchy:
global: Cluster-wide defaults apply to all namespaces (no namespace overrides allowed)namespace: Allows namespace-level overrides via ConfigMaps in individual namespaces
Configuration in TektonConfig
At the TektonConfig resource, the configuration of Pruner is roughly as follows:
Important: Tekton Pruner is a event-based pruner, and is disabled by default. To enable the event-based pruner, the existing job-based pruner MUST be disabled.
- Both pruners (
job-basedandevent-based) cannot be enabled simultaneously - The
event-basedpruner responds to resource events in real-time, providing more efficient cleanup
If you want to use job-based pruner, please refer to Regular Cleanup of TaskRun and PipelineRun Resources.
Explanation of YAML fields:
spec.pruner: This section contains the configuration forjob-basedpruner.disabled: Whether to disablejob-basedpruner.
spec.tektonpruner: This section contains the configuration forevent-basedpruner.disabled: Whether to disableevent-basedpruner.enforcedConfigLevel: determines the configuration hierarchy. For more detail, please refer to Namespace Configuration.global: Cluster-wide defaults apply to all namespaces (no namespace overrides allowed).namespace: Allows namespace-level overrides via ConfigMaps in individual namespaces.
ttlSecondsAfterFinished: Time in seconds to retain completed runs before pruning. For more detail, please refer to Time-based Pruning (TTL).historyLimit: Maximum number of runs to retain for each status (applies independently to both successful and failed runs). For more detail, please refer to History-based Pruning.successfulHistoryLimit: Maximum number of successful runs to retain. For more detail, please refer to History-based Pruning.failedHistoryLimit: Maximum number of failed runs to retain. For more detail, please refer to History-based Pruning.namespaces: Configure different default pruning policies for specific namespaces. For more detail, please refer to Namespace Configuration.options: The options for the Tekton Pruner controller. More detailed support can be found in Additional fields as options.