What is a Resolver?
A Resolver is a program that runs in a Kubernetes cluster alongside Tekton Pipelines and “resolves” requests for Tasks and Pipelines from remote locations. For example, if a user submits a PipelineRun that needs a Pipeline YAML stored in a custom storage system, your resolver would be responsible for fetching the YAML and returning it to Tekton Pipelines. This pattern allows integration with any storage backend without modifying Tekton Pipelines itself.Prerequisites
Before developing a custom resolver, you’ll need:- Proficiency in Go programming
- Understanding of Tekton Resolution concepts
- A Kubernetes cluster running Kubernetes 1.28 or later
kubectlinstalledkoinstalled for building container images- An image registry for pushing images (or
kind.localfor local development) - Tekton Pipelines v0.41.0+ and remote resolvers installed
Architecture Overview
A resolver consists of:- Go binary - Implements the resolver logic
- Kubernetes Deployment - Runs the resolver in the cluster
- Label-based routing - Directs ResolutionRequests to your resolver
- Framework integration - Uses Tekton’s resolver framework
Project Setup
Create the initial directory structure:cmd/demoresolver
Contains the resolver implementation
config
Contains Kubernetes deployment manifests
Implementing the Resolver
Createcmd/demoresolver/main.go with the following framework:
Main Entry Point
Required Interface Methods
Your resolver must implement theframework.Resolver interface:
Initialize Method
GetName Method
GetSelector Method
ResolutionRequest with label "resolution.tekton.dev/type": "demo" should be routed to your resolver.
Validate Method
Resolve Method
Implementing ResolvedResource
Create a type that implementsframework.ResolvedResource:
Best Practice: Implementing RefSource
For supply chain security (Tekton Chains integration), implementRefSource():
URI
Source location of the resource
Digest
Hash of the resource content
EntryPoint
Path to the specific resource
Deployment Configuration
Createconfig/demo-resolver-deployment.yaml:
Building and Deploying
Install dependencies:ko:
Testing Your Resolver
Createtest-request.yaml:
Using in PipelineRuns
Test your resolver with a real PipelineRun:Advanced Topics
Accepting Parameters
Modify theValidate and Resolve methods to accept parameters:
Adding Configuration
Create a ConfigMap for resolver settings:Error Handling
Return descriptive errors to help users troubleshoot:Example: Real-World Resolver
For a production-ready example, see the Git Resolver source code.Next Steps
Expand Resolve()
Implement fetching from your actual storage backend
Add Configuration
Create ConfigMaps for resolver settings
Implement Caching
Add caching for frequently accessed resources
Add Authentication
Implement authentication for protected backends
Resolver Template
For a complete resolver template to get started quickly, visit the resolver-template in the Tekton Pipeline repository.Framework Differences
Key Changes
Best Practices
Validate Inputs
Always validate parameters and URLs thoroughly
Return Provenance
Implement RefSource() for supply chain security
Handle Errors
Provide clear, actionable error messages
Use Timeouts
Respect the global 1-minute timeout limit
Secure Credentials
Store API tokens in Kubernetes secrets
Test Thoroughly
Test with various inputs and edge cases