Getting Started with Triggers

Create and run your first Tekton Trigger.

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

  1. Complete the two previous Getting Started tutorials: Tasks and Pipelines. Do not clean up your resources, skip the last section.

  2. 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:

  1. An EventListener object that listens to the world waiting for “something” to happen.

  2. A TriggerTemplate object, which configures a PipelineRun when this event occurs.

  3. A TriggerBinding object, that passes the data to the PipelineRun created by the TriggerTemplate object.

Triggers flow diagram

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

  1. Use kubectl to 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.yaml 
  2. Monitor the installation:

    kubectl get pods --namespace tekton-pipelines --watch 

    When tekton-triggers-controller, tekton-triggers-webhook, and tekton-triggers-core-interceptors show 1/1 under the READY column, 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 85s 

    Hit Ctrl + C to stop monitoring.

Create a TriggerTemplate

A TriggerTemplate defines what happens when an event is detected.

  1. Create a new file named trigger-template.yaml and 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 PipelineRun object that you created in the previous tutorial is now included in the template declaration. This trigger expects the username parameter to be available; if it’s not, it assigns a default value: “Kubernetes”.

  2. 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.

  1. Create a file named trigger-binding.yaml with 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 username variable.

  2. Apply the TriggerBinding:

    kubectl apply -f trigger-binding.yaml 

Create an EventListener

The EventListener object encompasses both the TriggerTemplate and the TriggerBinding.

  1. Create a file named event-listener.yaml and 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-template 

    This declares that when an event is detected, it will run the TriggerBinding and the TriggerTemplate.

  2. The EventListener requires a service account to run. To create the service account for this example create a file named rbac.yaml and 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-clusterroles 

    This service account allows the EventListener to create PipelineRuns.

  3. 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.

  1. Create the EventListener:

    kubectl apply -f event-listener.yaml 
  2. To communicate outside the cluster, enable port-forwarding:

    kubectl port-forward service/el-hello-listener 8080 

    The 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 -> 8080 

    Keep 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:

  1. Open a new terminal and submit a payload to the cluster:

    curl -v \  -H 'content-Type: application/json' \  -d '{"username": "Tekton"}' \  http://localhost:8080 

    You can change “Tekton” for any string you want. This value will be ultimately read by the goodbye-world Task.

    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 intact 
  2. This event triggers a PipelineRun, check the PipelineRuns on your cluster :

    kubectl get pipelineruns 

    The 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 34s 

    You see two PipelineRuns, the first one created in the previous guide, the last one was created by the Trigger.

  3. 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 -f 

    And you get the expected output:

    [hello : echo] Hello World [goodbye : goodbye] Goodbye Tekton! 

    Both Tasks completed successfuly. Congratulations!

Clean up

  1. Press Ctrl + C in the terminal running the port-forwarding process to stop it.

  2. Delete the cluster:

    minikube delete 

    The 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.


Last modified July 22, 2025: feat: refresh getting started (aa6e0f7)