Tekton Pipelines DSL for Jenkins with the Tekton Client Plugin

Project goal: Manage Tekton resources via Pipeline Steps / Jenkinsfile

Skills to study/improve: Java, Kubernetes, Tekton Pipelines

Details

Background

With the movement of traditional software architecture to microservices, there has been a growth in usage of container orchestration infrastructure (Kubernetes) and tooling around it. To adapt to this there have been plugins developed for Jenkins like the kubernetes-plugin which allow this transition to be smooth for the users to keep the same CI/CD platform and migrate their workloads.

Building on Kubernetes would mean that any CI/CD tool which has been Kubernetes-native built with building on Kubernetes as it’s main idea would thrive better than Jenkins itself. Leveraging this, we can use the capability of spinning pipelines on Tekton (Serverless CI/CD for Kubernetes) through Jenkins. Using the same vocabulary and ideas to execute Jobs from Jenkins and having the workloads of the Jobs run by Tekton in Kubernetes, this plugin aims to bridge the gap between Jenkins and Kubernetes.

The Tekton Client Plugin allows users to create/delete resources via Build Steps but there is no way for users to employ their preexisting Jenkinsfile to extend their Jenkins pipeline to leverage Tekton for deploying on Kubernetes.

With no DSL for Tekton on Jenkins there is no way for the users to write scripts which can automate their Tekton lifecycle through Jenkins.

Project Details

Create a DSL to interact with Tekton supported by Jenkins.

Quick-start

To work with Tekton Client Plugin, having a Kubernetes cluster is essential. A Minikube or KIND kubernetes cluster is sufficient to begin with development on the plugin.

Installing kubectl

kubectl is a commandline tool used to interact with Kubernetes clusters. We would be using it here to understand the state of the resources

Installing KIND

Follow this quick start guide to install a KIND cluster.

Create a cluster using kind cli.

kind create cluster

Check cluster installation

kubectl get pods -n kube-system

The output should contain pods which are in the Running state.

Installing Tekton on your Kubernetes cluster

Follow this github doc and install the latest release of Tekton Pipeline on your k8s cluster.

Check Tekton installation

kubectl get pods -n tekton-pipelines

The output should contain pods which are in the Running state.

Installing Tekton CLI

The Tekton CLI would be used to better debug and work with Tekton Pipelines. Use this github doc to install Tekton CLI.

Create a Tekton resource using Jenkins + Tekton Client Plugin

Start a Jenkins instance with the plugin installed

Running a Tekton pipeline using the plugin is the best way to get acquainted to the plugin. Once we have a kubernetes cluster running with Tekton installed we can start the plugin in development mode and create a tekton resources from the Jenkins console.

Clone and run the plugin in development mode.

git clone https://github.com/jenkinsci/tekton-client-plugin
cd tekton-client-plugin
mvn hpi:run
Create a Tekton TaskRun

Browse to localhost:8080/jenkins which will take you to the Jenkins console. - Create a new Freestyle Project / Job by navigating to the New Item button on the top left corner of the screen. Choose Freestyle Project, give a name and click on Ok. This will take us to the job configuration next. - In the job configuration, scroll down to the Build sub header. From the "Add build step` drop down, choose Tekton : Create Resource (Raw). This will add a Build step to the configuration which will help us create a Tekton resource. - In the Tekton createRaw build step configuration, choose the Input Type as URL and add the following url as the input.

https://raw.githubusercontent.com/tektoncd/pipeline/main/examples/v1beta1/taskruns/task-result.yaml
This would create a TaskRun running a Task in Tekton.
Checking the state of TaskRun using the Tekton CLI.

Run the following commands to check the state of the TaskRun and the get the logs for the same respectively.

tkn taskrun list
tkn taskrun logs -f
Checking the state of TaskRun from the Jenkins Console

Go to the Jenkins console for the Job to see the output of the TaskRun from Jenkins.

Next Steps

To explore the Tekton Client Plugin further, check out more of the documentation and the github issues to understand current landscape of the plugin and future work.

Newbie-friendly issues

Skills to improve/study

  • Java

  • Docker,Kubernetes

  • Jenkins

  • Tekton Pipelines

Potential Mentors

Project Links

Organization Links

> Go back to other GSoC 2021 project ideas