Tekton Results
Tekton Results is a sophisticated system that extends Tekton's capabilities by providing persistent storage, querying, and management of CI/CD execution data. This document provides a deeper exploration of how Tekton Results works, its architecture, and how to leverage its features effectively.
TOC
Glossary
Why We Need Tekton Results
The Challenge of CI/CD Data Management
In traditional Kubernetes-based CI/CD systems like Tekton Pipelines, all execution data is stored in the Kubernetes API server's etcd database. This approach has several limitations:
- Limited Storage Capacity: etcd is designed for storing small amounts of configuration data, not large volumes of execution history and logs
- Resource Constraints: As CI/CD workloads accumulate, they can consume significant etcd resources, potentially affecting cluster performance
- Data Fragmentation: Related CI/CD activities (TaskRuns, PipelineRuns) are stored as separate resources without explicit relationships
- Log Management: Logs are typically stored in the container runtime or external logging systems, making it difficult to associate them with specific pipeline executions
- Data Lifecycle: There's no built-in mechanism for managing the lifecycle of completed CI/CD data
These limitations become increasingly problematic as CI/CD usage scales, leading to potential performance issues and administrative overhead.
How Tekton Results Addresses These Challenges
Tekton Results provides a comprehensive solution by:
- Offloading Data Storage: Moving completed CI/CD execution data from etcd to a dedicated database optimized for this purpose
- Establishing Relationships: Creating explicit relationships between related CI/CD activities through the Result/Record data model
- Centralizing Log Storage: Storing logs alongside their associated TaskRuns/PipelineRuns
- Providing Data Lifecycle Management: Implementing retention policies to automatically manage data over time
- Enabling Advanced Querying: Offering powerful filtering and querying capabilities beyond what's possible with the Kubernetes API
Advantages
- Improved Cluster Performance: Reduces load on the Kubernetes API server and etcd by offloading completed CI/CD data
- Enhanced Data Organization: Groups related CI/CD activities together for better visibility and management
- Longer Data Retention: Enables long-term storage of execution history without impacting cluster resources
- Powerful Querying: Provides advanced filtering and search capabilities for CI/CD data
- Integrated Log Management: Stores logs alongside execution data for comprehensive pipeline history
- Automated Cleanup: Manages data lifecycle through configurable retention policies
Applicable Scenarios
Tekton Results is particularly valuable in the following scenarios:
- High-Volume CI/CD Environments: Organizations running numerous pipelines that generate substantial execution data
- Compliance Requirements: Environments that need to maintain execution history for audit or compliance purposes
- Resource-Constrained Clusters: Clusters where etcd resources are limited and need to be optimized
- Advanced Analytics: Teams that want to perform analysis and reporting on CI/CD execution patterns
- Multi-Team Environments: Organizations where multiple teams share Tekton infrastructure and need isolated views of their CI/CD data
Architecture and Principles
Tekton Results follows a microservices architecture with three main components that work together to provide a complete solution:
API Server Architecture
The API Server is the central component that:
- Provides Data Access: Exposes gRPC and REST endpoints for storing and retrieving Results and Records
- Manages Authentication: Uses Kubernetes-style authentication (service accounts, tokens)
- Enforces Authorization: Implements RBAC-based access control for Results resources
- Handles Data Persistence: Interfaces with the underlying database (PostgreSQL)
- Supports Filtering: Implements CEL (Common Expression Language) for powerful query filtering
The API Server uses a parent-child hierarchy where:
- Namespaces/workspaces are parents of Results
- Results are parents of Records
- Records contain the actual execution data
Watcher Architecture
The Watcher operates as a Kubernetes controller that:
- Monitors Resources: Listens for TaskRun and PipelineRun events in the cluster
- Determines Grouping: Uses annotations, labels, and owner references to group related resources
- Creates/Updates Records: Stores execution data in the Results database via the API Server
- Annotates Resources: Adds Result identifiers to the original Kubernetes resources
- Manages Deletion: Optionally deletes completed resources after they're stored in the database
The Watcher uses several strategies to group related resources:
results.tekton.dev/resultannotationtriggers.tekton.dev/triggers-eventidlabel- Owner references to PipelineRuns
- Automatic generation of new Result names when no grouping information is found
Retention Policy Agent Architecture
The Retention Policy Agent is responsible for:
- Scheduling Cleanup: Running pruning jobs according to a configured schedule
- Enforcing Retention: Removing data that exceeds the configured retention period
- Managing Database Size: Preventing unbounded growth of the Results database
Data Model In-Depth
Result Structure
A Result contains:
Record Structure
A Record contains:
Authentication and Authorization
Tekton Results uses Kubernetes-style authentication and RBAC for access control:
- Authentication: Uses service account tokens, user impersonation, and other Kubernetes authentication methods
- Authorization: Implements RBAC with resources (
results,records) and verbs (get,list,create,update,delete) - Namespace Isolation: Scopes permissions per namespace for multi-tenant environments
Example RBAC roles:
tekton-results-readonly: Read-only access to Results and Recordstekton-results-readwrite: Read and write access to Results and Recordstekton-results-admin: Full access including deletion of Results and Records
Advanced Filtering
Tekton Results uses CEL (Common Expression Language) for powerful filtering capabilities: