Getting Started with Triggers
This tutorial shows you how to
- Install Tekton Triggers.
- Create a TriggerTemplate.
- Create a TriggerBind.
- Create an EventListener.
This guide uses a local cluster with minikube.
Before you begin
Complete the two previous Getting Started tutorials: Tasks and Pipelines. Do not clean up your resources, skip the last section.
Install curl if it’s not already available on your system.
Overview
You can use Tekton Triggers to modify the behavior of your CI/CD Pipelines depending on external events. The basic implementation you are going to create in this guide comprises three main components:
An
EventListenerobject that listens to the world waiting for “something” to happen.A
TriggerTemplateobject, which configures a PipelineRun when this event occurs.A
TriggerBindingobject, that passes the data to the PipelineRun created by theTriggerTemplateobject.
An optional ClusterInterceptor object can be added to validate and process
event data.
You are going to create a Tekton Trigger to run the hello-goodbye Pipeline
when the EventListener detects an event.
Install Tekton Triggers
Use
kubectlto install Tekton Triggers:kubectl apply --filename \ https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml kubectl apply --filename \ https://storage.googleapis.com/tekton-releases/triggers/latest/interceptors.yamlMonitor the installation:
kubectl get pods --namespace tekton-pipelines --watchWhen
tekton-triggers-controller,tekton-triggers-webhook, andtekton-triggers-core-interceptorsshow1/1under theREADYcolumn, you are ready to continue. For example:NAME READY STATUS RESTARTS AGE tekton-events-controller-786b59d5cd-jt7d9 1/1 Running 0 5m43s tekton-pipelines-controller-59b6cdbbc-2kw2w 1/1 Running 0 5m43s tekton-pipelines-webhook-74b5cdfcc4-g4qj2 1/1 Running 0 5m43s tekton-triggers-controller-784d896c7f-s5c7s 1/1 Running 0 85s tekton-triggers-core-interceptors-54d9f764b-g5vbh 1/1 Running 0 84s tekton-triggers-webhook-666c844478-4cqcv 1/1 Running 0 85sHit Ctrl + C to stop monitoring.
Create a TriggerTemplate
A TriggerTemplate defines what happens when an event is detected.
Create a new file named
trigger-template.yamland add the following:apiVersion: triggers.tekton.dev/v1beta1 kind: TriggerTemplate metadata: name: hello-template spec: params: - name: username default: "Kubernetes" resourcetemplates: - apiVersion: tekton.dev/v1 kind: PipelineRun metadata: generateName: hello-goodbye-run- spec: pipelineRef: name: hello-goodbye params: - name: username value: $(tt.params.username)The
PipelineRunobject that you created in the previous tutorial is now included in the template declaration. This trigger expects theusernameparameter to be available; if it’s not, it assigns a default value: “Kubernetes”.Apply the TriggerTemplate to your cluster:
kubectl apply -f trigger-template.yaml
Create a TriggerBinding
A TriggerBinding executes the TriggerTemplate, the same way you had to create a PipelineRun to execute the Pipeline.
Create a file named
trigger-binding.yamlwith the following content:apiVersion: triggers.tekton.dev/v1beta1 kind: TriggerBinding metadata: name: hello-binding spec: params: - name: username value: $(body.username)This TriggerBinding gets some information and saves it in the
usernamevariable.Apply the TriggerBinding:
kubectl apply -f trigger-binding.yaml
Create an EventListener
The EventListener object encompasses both the TriggerTemplate and the
TriggerBinding.
Create a file named
event-listener.yamland add the following:apiVersion: triggers.tekton.dev/v1beta1 kind: EventListener metadata: name: hello-listener spec: serviceAccountName: tekton-robot triggers: - name: hello-trigger bindings: - ref: hello-binding template: ref: hello-templateThis declares that when an event is detected, it will run the TriggerBinding and the TriggerTemplate.
The EventListener requires a service account to run. To create the service account for this example create a file named
rbac.yamland add the following:apiVersion: v1 kind: ServiceAccount metadata: name: tekton-robot --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: triggers-example-eventlistener-binding subjects: - kind: ServiceAccount name: tekton-robot roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: tekton-triggers-eventlistener-roles --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: triggers-example-eventlistener-clusterbinding subjects: - kind: ServiceAccount name: tekton-robot namespace: default roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: tekton-triggers-eventlistener-clusterrolesThis service account allows the EventListener to create PipelineRuns.
Apply the file to your cluster:
kubectl apply -f rbac.yaml
Running the Trigger
You have everything you need to run this Trigger and start listening for events.
Create the EventListener:
kubectl apply -f event-listener.yamlTo communicate outside the cluster, enable port-forwarding:
kubectl port-forward service/el-hello-listener 8080The output confirms that port-forwarding is working:
kubectl port-forward service/el-hello-listener 8080 Forwarding from 127.0.0.1:8080 -> 8080 Forwarding from [::1]:8080 -> 8080Keep this service running, don’t close the terminal.
Monitor the Trigger
Now that the EventListener is running, you can send an event and see what happens:
Open a new terminal and submit a payload to the cluster:
curl -v \ -H 'content-Type: application/json' \ -d '{"username": "Tekton"}' \ http://localhost:8080You can change “Tekton” for any string you want. This value will be ultimately read by the
goodbye-worldTask.The response is successful:
< HTTP/1.1 202 Accepted < Content-Type: application/json < Date: Mon, 21 Jul 2025 22:03:34 GMT < Content-Length: 164 < {"eventListener":"hello-listener","namespace":"default","eventListenerUID":"c2905e72-8036-4f6a-b26e-f390e8615b76","eventID":"8747199c-b96e-488c-9c44-d43b368b877b"} * Connection #0 to host localhost left intactThis event triggers a PipelineRun, check the PipelineRuns on your cluster :
kubectl get pipelinerunsThe output confirms the pipeline is working:
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME hello-goodbye-run True Succeeded 6m24s 6m2s hello-goodbye-run-r4qg4 True Succeeded 44s 34sYou see two PipelineRuns, the first one created in the previous guide, the last one was created by the Trigger.
Check the PipelineRun logs. The name is auto-generated adding a suffix for every run, in this case it’s
hello-goodbye-run-8hckl. Use your own PiepelineRun name in the following command to see the logs:tkn pipelinerun logs --last -fAnd you get the expected output:
[hello : echo] Hello World [goodbye : goodbye] Goodbye Tekton!Both Tasks completed successfuly. Congratulations!
Clean up
Press Ctrl + C in the terminal running the port-forwarding process to stop it.
Delete the cluster:
minikube deleteThe output confirms that the cluster was deleted:
🔥 Deleting “minikube” in qemu2 … 💀 Removed all traces of the “minikube” cluster. ```
Further reading
For more complex Pipelines examples check:
You can find more Tekton Triggers examples on the Triggers GitHub repository.