Kubernetes API Event Driven Triggering of Tekton Pipelines

Posted: March 30th, 2021 | Author: | Filed under: Technology | Tags: , , , | No Comments »

Validating the Integration

With both the Tekton and Knative components deployed and integrated, let’s validate the solution by creating a new application and deploying it to the cluster. The process of building a new application and pushing it to the integrated OpenShift registry will result in a new Image resource being created and trigger the Tekton Pipeline as the event is consumed.

Navigate to the OpenShift web console and switch to the Developer Perspective using the dropdown on the top left corner of the page.

Create a new Project to contain the application by selecting the Project dropdown and select Create Project

Enter sample-image-event into the Name textbox and select Create to create the project.

Navigate to the Developer Catalog by selecting the Add button and then selecting From Catalog.

Deploy a sample Python Django application by selecting Languages on the left hand side and then selecting Python.

Select the Django + PostgreSQL (Ephemeral) template and then click Instantiate Template.

Review the options and make any modifications as necessary, but no changes are required by default. Click Create to instantiate the template.

In a moment, a new build will be created, and once complete, a new image will be pushed to OpenShift’s integrated registry. 

The APIServerSource will detect the change and start the Tekton pipeline. List all Tekton PipelineRun’s in the image-watcher namespace to confirm the event was captured.

oc get pipelinerun -n image-watcher

NAME                SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
print-image-w7bhs   True        Succeeded   26s         20s

Viewing the PipelineRun logs confirms the parameters were successfully passed from the CloudEvent produced by the APIServerSorurce and parsed into the PipelineRun parameters:

tkn pipelinerun logs -L

[print-image : print-image] Event Type: dev.knative.apiserver.resource.add
[print-image : print-image] Image Name: sha256:7ad4357b417b4e395c0dbaa0711fd62f04613b5a4aac71105bb92c335923294b
[print-image : print-image] Image Reference: image-registry.openshift-image-registry.svc:5000/sample-image-event/django-psql-example@sha256:7ad4357b417b4e395c0dbaa0711fd62f04613b5a4aac71105bb92c335923294b

By capturing the name of the image and image reference, the pipeline can then use these values and apply the necessary business logic to conform to the organizational requirements to ensure.

Technologies, such as Tekton and Knative, open up the door for applying new methods for solving important challenges. By combining the features found in Tekton’s Pipeline and Triggers projects to provide a workflow oriented approach towards software security, with the decoupled nature of Knative eventing to incorporate events a wide range of origination points, it has never been easier to build a robust Trusted Software Supply Chain. 



Leave a Reply