Design
Architecture and design patterns of the Porch controllers.
The Porch Controllers are Kubernetes controllers which form the backend to Porch’s higher-level Custom Resources and automatically create and manage PackageRevisions through the Porch API. They provide declarative, template-based automation for creating multiple downstream variants of a package from a single upstream package.
Responsibilities:
The Controllers sit above the Porch API Server and act as automation clients:
┌─────────────────────────────────────────────────────┐
│ Controllers │
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ PackageVariant │ │PackageVariantSet │ │
│ │ Controller │<────│ Controller │ │
│ │ │ │ │ │
│ │ • Watch PV CRs │ │ • Watch PVS CRs │ │
│ │ • Create/Update │ │ • Generate PV │ │
│ │ PackageRevs │ │ CRs │ │
│ │ • Sync Upstream │ │ • Target Select │ │
│ └────────┬─────────┘ └──────────────────┘ │
│ │ │
└─────────────┴───────────────────────────────────────┘
↓
Porch API Server
↓
PackageRevisions
Key architectural responsibilities:
Declarative Package Management: Enables users to declare desired package variants rather than manually creating each PackageRevision
Automation Layer: Bridges the gap between high-level intent (PackageVariant/PackageVariantSet) and low-level operations (PackageRevision CRUD)
Multi-Target Distribution: PackageVariantSet controller enables creating variants across multiple repositories or for multiple targets from a single declaration
Change Detection and Reconciliation:
Template-Based Generation: Uses templates with CEL expressions to dynamically generate package configuration based on target context
Ownership Management:
Manages individual package variants - one upstream package to one downstream package relationship. Creates downstream PackageRevisions (clones, upgrades, edits) and applies mutations (package context, pipeline functions, injections).
Manages bulk creation of PackageVariant CRs based on target selectors. Evaluates target selectors (repositories, repository selector, object selector) and generates PackageVariant CRs for each matching target using CEL expression templates.
The controllers are clients of the Porch API, not part of the Porch server. They run as a separate deployment using standard Kubernetes client-go to interact with Porch API, and can be enabled/disabled independently using
the --reconcilers flag.
Controller runtime:
The controllers are instantiated once during startup and run continuously, reconciling resources as they change.
Architecture and design patterns of the Porch controllers.
Controller for managing PackageVariant resources.
Controller for managing PackageVariantSet resources.
Overview of controller functionality and detailed documentation pages.
How the Porch controllers interact with Porch APIs.