Architecture Overview
PAC consists of three main components that work together to process Git events and manage pipeline executions:Core Components
Controller
Binary:pipelines-as-code-controller
Responsibilities:
- Receives webhook events from Git providers
- Validates event authenticity and permissions
- Resolves pipeline definitions from
.tekton/directory - Creates PipelineRuns on the Kubernetes cluster
- Manages concurrency and queueing
- Handles GitOps commands (
/test,/retest,/cancel)
pkg/adapter: Event processing and webhook handlingpkg/matcher: Matches events against pipeline annotationspkg/provider: Git provider integrations (GitHub, GitLab, etc.)pkg/acl: Access control and permission validationpkg/pipelineascode: Core pipeline processing logic
cmd/pipelines-as-code-controller/main.go
Watcher
Binary:pipelines-as-code-watcher
Responsibilities:
- Watches PipelineRun resources for status changes
- Reports status back to Git providers (checks, comments, badges)
- Manages PipelineRun cleanup based on retention policies
- Handles concurrency queue processing
- Updates Repository CRD status
pkg/reconciler: PipelineRun reconciliation logicpkg/kubeinteraction: Kubernetes API interactionspkg/formatting: Status formatting for different providerspkg/queue: Concurrency queue management
cmd/pipelines-as-code-watcher/main.go
Webhook Handler
Binary:pipelines-as-code-webhook (embedded in controller)
Responsibilities:
- Receives HTTP webhook requests from Git providers
- Validates webhook signatures
- Routes events to the controller
- Handles incoming webhook feature for manual triggers
cmd/pipelines-as-code-webhook/main.go
Event Flow
Here’s how a typical pull request event flows through the system:Event Validation
The webhook handler:
- Verifies the webhook signature
- Validates the event payload
- Checks for skip CI markers (
[skip ci],[ci skip])
Repository Lookup
The controller:
- Finds the matching Repository CRD
- Retrieves authentication credentials
- Validates the repository configuration
Permission Check
The ACL system validates:
- User is authorized (org member, collaborator, or in OWNERS file)
- Pull request doesn’t require
/ok-to-testapproval - Event matches allowed event types
Pipeline Resolution
The resolver:
- Fetches
.tekton/directory from the repository - Matches pipelines to the event using annotations
- Resolves remote tasks from Tekton Hub or Artifact Hub
- Substitutes template variables (
{{repo_url}},{{revision}}, etc.)
PipelineRun Creation
The controller creates a PipelineRun resource on Kubernetes with:
- Resolved pipeline definition
- Workspaces and secrets
- Labels and annotations for tracking
Execution
Tekton Pipelines executes the PipelineRun:
- Creates pods for each task
- Runs the pipeline steps
- Manages task dependencies and workspaces
Status Monitoring
The watcher:
- Monitors PipelineRun status changes
- Reports progress to the Git provider
- Updates GitHub Checks, GitLab MR notes, etc.
Key Design Patterns
Repository CRD
TheRepository Custom Resource Definition (CRD) is the central configuration object:
- Maps Git repositories to Kubernetes namespaces
- Stores authentication credentials
- Configures provider-specific settings
- Tracks PipelineRun history and status
Event Matching
Pipelines are matched to events using annotations:- Check
on-eventannotation matches event type - Verify
on-target-branchmatches target branch - Evaluate
on-cel-expressionif present - Check
on-path-changeif file patterns specified
pkg/matcher
Pipeline Resolution
The resolver processes pipeline definitions: Steps:- Fetch
.tekton/directory from the repository at the event revision - Parse YAML files for PipelineRun resources
- Match pipelines to the event
- Resolve remote tasks using
resolverfield: - Substitute template variables:
{{repo_url}}→ Repository clone URL{{revision}}→ Git SHA{{target_branch}}→ PR target branch{{source_branch}}→ PR source branch
pkg/pipelineascode/resolve
Access Control (ACL)
PAC implements a flexible ACL system: Permission Levels:- Repository admins: Full access
- Organization members: Can trigger pipelines
- Collaborators: Can trigger pipelines if configured
- OWNERS file: Custom approval rules
/ok-to-test: Manual approval for untrusted PRs
pkg/acl
Concurrency Control
PAC manages pipeline execution concurrency: Annotation:- PipelineRuns exceeding concurrency limit are queued
- State:
queued→started→completed - FIFO queue per repository
- Automatic promotion when slots become available
pkg/queue
Provider Integrations
PAC supports multiple Git providers through a common interface:Provider Interface
All providers implement theInterface in pkg/provider/interface.go:
Supported Providers
- GitHub
- GitLab
- Forgejo
- Bitbucket
Package:
pkg/provider/githubFeatures:- GitHub App authentication
- Webhook authentication
- GitHub Checks API integration
- Line annotations for errors
- Re-run from UI support
- GitHub App (recommended)
- Personal Access Token
Package Structure
Here’s an overview of the main packages:Configuration and Settings
PAC is configured through:ConfigMap Settings
Name:pipelines-as-code (in pipelines-as-code namespace)
Common Settings:
Repository-Level Settings
Settings can be overridden per repository:Secrets Management
PAC uses Kubernetes secrets for:Git Provider Credentials
Webhook Secrets
Pipeline Secrets
Secrets for use within pipelines:Logging and Observability
Structured Logging
PAC uses structured JSON logging:Log Levels
Configure via ConfigMap:Performance Considerations
Resource Requirements
Controller:- CPU: 100m - 500m
- Memory: 128Mi - 512Mi
- CPU: 50m - 200m
- Memory: 64Mi - 256Mi
Scaling
- Controllers run in active/passive mode (leader election)
- Watchers can run multiple replicas
- Use horizontal pod autoscaling for high-traffic scenarios
Optimization Tips
- Use concurrency limits to prevent cluster overload
- Configure PipelineRun retention (
max-keep-runs) - Enable remote task caching
- Use volume workspaces instead of PVCs for better performance
Security Architecture
Webhook Signature Validation
All webhooks are cryptographically verified:- GitHub: HMAC-SHA256 signature
- GitLab: Secret token validation
- Bitbucket: HMAC-SHA256 signature
- Forgejo: Optional signature validation
Secret Redaction
Secrets are automatically redacted from:- GitHub Checks annotations
- Log outputs in comments
- PipelineRun status messages
RBAC
PAC requires specific Kubernetes permissions:Extension Points
Custom Parameters
Inject custom parameters into PipelineRuns: Package:pkg/customparams
LLM Integration
PAC includes experimental LLM integration for:- Automatic issue analysis
- Error explanation
- Suggested fixes
pkg/llm
Next Steps
Event Flows
See detailed event flow diagrams
Testing Guide
Learn how to test PAC components
Development Setup
Set up your development environment
Contributing
Start contributing to PAC