Exposing an EventListener outside of the cluster, we can expose this service using the below options
- Using a LoadBalancer Service type
- Using a Kubernetes Ingress object
- Using the NGINX Ingress Controller
- Using OpenShift Route
I am using a LoadBalancer Service type in the GCP Kubernetes cluster to trigger the event listener. I have the below tekton event listener
apiVersion: triggers.tekton.dev/v1beta1kind: EventListenermetadata: name: bitbucket-listener namespace: fetebird-commonspec: serviceAccountName: gcp-service-account triggers: - name: bitbucket-triggers interceptors: - ref: name: "bitbucket" params: - name: eventTypes value: - repo:push bindings: - ref: bitbucket-trigger-binding template: ref: bitbucket-trigger-template
I have created a Load Balancer service as below
apiVersion: v1kind: Servicemetadata: name: bitbucket-eventlistener-lb namespace: fetebird-commonspec: selector: eventlistener: bitbucket-listener ports: - protocol: TCP port: 80 targetPort: 30580 # Adjust this to the actual target port of your EventListener type: LoadBalancer
The external Ip of the cluster, is as below
kubectl get svc bitbucket-eventlistener-lb -n fetebird-common -o wideNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTORbitbucket-eventlistener-lb LoadBalancer 10.60.9.24 35.193.230.47 80:30758/TCP 5m49s eventlistener=bitbucket-listener
CURL
curl -v \-H 'X-Event-Key: repo:push' \-d '{"push": {"changes":[{"old":{}, "new":{"name":"bb-cloud-test-1"}}]},"repository":{"links": {"html":{"href": "https://bitbucket.org/savitaredhat/bitbuckettest-customer"}},"name":"bitbuckettest-customer"}, "actor":{"display_name": "savita"}}' \http://35.193.230.47
Exception
* Trying 35.193.230.47:80...* connect to 35.193.230.47 port 80 failed: Connection refused* Failed to connect to 35.193.230.47 port 80 after 203 ms: Couldn't connect to server* Closing connection 0curl: (7) Failed to connect to 35.193.230.47 port 80 after 203 ms: Couldn't connect to server
With PORT Exception
* Trying 35.193.230.47:30758...* connect to 35.193.230.47 port 30758 failed: Operation timed out* Failed to connect to 35.193.230.47 port 30758 after 75004 ms: Couldn't connect to server* Closing connection 0curl: (28) Failed to connect to 35.193.230.47 port 30758 after 75004 ms: Couldn't connect to server