Tekton Triggers ships with the ClusterInterceptor
Custom Resource Definition (CRD), which allows you to implement a custom cluster-scoped Webhook-style Interceptor
.
A ClusterInterceptor
specifies an external Kubernetes v1 Service running custom business logic that receives the event payload from the
EventListener
via an HTTP request and returns a processed version of the payload along with an HTTP 200 response. The ClusterInterceptor
can also
halt processing if the event payload does not meet criteria you have configured as well as add extra fields that are accessible in the EventListener's
top-level extensions
field to other Interceptors
and ClusterInterceptors
chained with it and the associated TriggerBinding
.
A ClusterInterceptor
definition consists of the following fields:
- Required:
apiVersion
- specifies the target API version, for exampletriggers.tekton.dev/v1alpha1
kind
- specifies that this Kubernetes resource is aClusterInterceptor
objectmetadata
- specifies data that uniquely identifies thisClusterInterceptor
object, for example aname
spec
- specifies the configuration information for thisClusterInterceptor
object, including:- [
clientConfig
] - specifies how a client, such as anEventListener
communicates with thisClusterInterceptor
object
- [
The clientConfig
field specifies the client, such as an EventListener
and how it communicates with the ClusterInterceptor
to exchange
event payload and other data. You can configure this field in one of the following ways:
- Specify the
url
field and as its value a URL at which the corresponding Kubernetes service listens for incoming requests from thisClusterInterceptor
- Specify the
service
field and within it reference the corresponding Kubernetes service that's listening for incoming requests from thisClusterInterceptor
For example:
spec:
clientConfig:
url: "http://interceptor-svc.default.svc/"
---
spec:
clientConfig:
service:
name: "my-interceptor-svc"
namespace: "default"
path: "/optional-path" # optional
port: 8081 # defaults to 80
The Kubernetes object running the custom business logic for your ClusterInterceptor
must meet the following criteria:
- Fronted by a regular Kubernetes v1 Service listening on an HTTP port (default port is 80)
- Accepts an HTTP
POST
request that contains anInterceptorRequest
as a JSON body - Returns an HTTP 200 OK response that contains an
InterceptorResponse
as a JSON body - Returns a response other than HTTP 200 OK only if payload processing halts due to a catastrophic failure