TECH BASICS

Getting Started with Tekton

What is Cloud Native?

The term cloud native was first used by Bill Wilder in his book, Cloud Architecture Patterns. He mentioned, a cloud-native application is any application that was architected to take full advantage of cloud platforms.

As per Cloud Native Computing Foundation :

Cloud-native technologies empower organizations to build and run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach.

These techniques enable loosely coupled systems that are resilient, manageable, and observable. Combined with robust automation, they allow engineers to make high-impact changes frequently and predictably with minimal toil.

What is Kubernetes Native?

Kubernetes has now become the de-facto standard for container orchestration. Kubernetes Native app development focuses on Kuberenets based deployment, orchestration.

What is Cloud Native CI/CD?

Being cloud native means, effectively utilizing modern cloud technologies. Cloud native CI/CD should be able to support Cloud Native Dev Cycle. It should be able to deploy and manage workloads using containers and runs in serverless mode.

Jenkins-X, Spinnaker, Tekton are examples of Cloud Native CI/CD tools/

What is Tekton?

  • Kubernetes-native open-source framework for creating CI/CD systems
  • Supports hybrid or multi-cloud deployment model
  • Serverless model
  • It provides feature of Artifact Management as well
  • part of CD Foundation, a Linux Foundation project.

As per Red Hat,

Tekton attempts to fill the void of an in-cluster container image build and deployment workflow — that is continuous integration (CI) and continuous delivery (CD)

Why Tekton is different?

Tekton’s decoupled nature is its core strength, meaning that one pipeline can be used to deploy to any Kubernetes cluster across multiple hybrid cloud providers.

Tekton stores everything related to a pipeline within the cluster, allowing reutilisation across multiple pipelines.

Tekton Eco-System?

Following are the main components in Tekton Eco System.

  1. Tekton Kubernetes Operator — Kubernetes Deployment Operator
  2. Tekton CLI —Command line Utility similar to kubectl to support tkn
  3. Tekton Pipelines — building blocks for CI/CD pipelines
  4. Tekton Catalogue — community-contributed Tekton building blocks
  5. Tekton Hub — Online Web Hub for Tekton Catalog
  6. Tekton Dashboard — web-based UI for Tekton Pipelines and Tekton triggers resources

How do I connect/manage with Tekton Pipelines?

You have following options to connect with Tekton -

  • via Kubectl or OC(OpenShift) utility
  • via Tekton CLI
  • Tekton APIs

Installing Tekton CLI

Installing Tekton CLI is pretty straight forward. There are multiple options available, selects which suits you most.

$ curl -LO https://github.com/tektoncd/cli/releases/download/v0.18.0/tkn_0.18.0_Linux_x86_64.tar.gz

$ sudo tar xvzf tkn_0.18.0_Linux_x86_64.tar.gz -C /usr/local/bin/ tkn
$ tkn version

How these Tekton Pipeline resources are available in Kubernetes ?

Tekton installs a set of Custom Resource (CRDs)extensions to your Kubernetes cluster that define pipelines and related concepts.

How Tekton Catalogue and Hub Is helping?

Tekton catalogue contains community-contributed reusable Tasks and are published on Hub. You can utilise them in your own pipelines.

Tekton Catalogue

Tekton Pipelines

What is pipeline? Pipelines are mechanism mostly running processes that implements serialised automation for build, test and deployment of your code or software. Tekton Pipelines provides Kubernetes-style, YAML based resources for declaring CI/CD-style pipelines. Following are list of CRDs get deployed when you deploy Tekton on Kubernetes Cluster.

Task: Sequence of steps that are run in isolation (in a pod).
TaskRun: Used for Execution of a task
Pipeline: Collection of tasks, executed in a defined order
PipelineResource: Provide Inputs (e.g. git repo) and outputs (e.g. image registry) to a pipeline.
PipelineRun: Used for Execution of a pipeline.

Tekton work on the concept of Tasks, which specify the workloads you want to run. Task defines a series of ordered Steps.These tasks stitched together and form a pipeline. A task can be very simple or can become much more complex. Tasks can have inputs, outputs etc. Tekton stores the output of all Tasks which can be referred later as well. To run a task you can create another type of resource called TaskRun. It instantiates a specific Task to execute on a particular set of inputs and produce a particular set of outputs.

You can deploy above script via downloading it and see the results by your self.

$ kubectl apply -f tekton_task_taskrun.yaml$ kubectl get pods
NAME READY STATUS RESTARTS AGE
task-run-pod-fxz5z 0/1 Completed 0 104s

As you can see above a container executed for the task with required arguments and exists. Logs of task can be checked using tkn utility -

$ tkn taskrun logs task-run
[hello-task] Hello Tekton

Please note each Task in Tekton executes in its own Kubernetes Pod(container). Thus, by default, Tasks within a Pipeline do not share data.

Let’s move forward and understand Pipeline. In above example we have created a simple task and ran it. Now if we have more advance scenario where we need to execute advance series of tasks who can take inputs and produce outputs etc Pipeline and PipelineResources comes to help. Pipelinedefines a series of ordered Tasks. PipelineResourcesin a pipeline are the set of objects that are going to be used as inputs to a Task and can be output by a Task. To execute a pipeline, PipelineRun comes to help.

Let’s create a sample pipeline with tasks. Following pipeline just execute the above task twice in serialised manner.

$ kubectl apply -f tk_pipeline.yaml
pipeline.tekton.dev/tk-pipeline-hello created
pipelinerun.tekton.dev/tk-pipeline-run-hello created
$ tkn pipeline logs tk-pipeline-hello
? Select pipelinerun: tk-pipeline-run-hello-r-6pdwz started 2 hours ago
[this-is-first-task : hello-task] Hello Tekton
[this-is-second-task : hello-task] Hello Tekton
Tekton Pipeline run

How to Install Tekton?

Tekton can run on any Kubernetes cluster. For this post, I have created a cluster using Kubeadm. Let’s start the deployment -

$ kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml# you can modify the above YAML for deployment as well. This YAML consists all of the kubernetes objects required for deployment of tekton.
Installing Tekton

Check the CRDs in above screenshot!

By default it will deploy PODs in tekton-pipelines namespace. You can modify the YAML as per your convenience. Once deployment is done, you can see 2 pods will be running in your namespace.

$ kubectl get pods --namespace tekton-pipelines

That’s it, you Tekton deployment is over and ready for usage.

Is there any GUI based system for viewing Tekton Specific Tasks or Pipelines?

Tekton Dashboard is also available for viewing pipelines. It web-based UI for Tekton Pipelines and Tekton triggers resources. You can directly create Tekton objects and execute them.

How can I install Tekton Dashboard?
Installing dashboard is fairly simple process. Just run the following kubectl command against your cluster -

$ kubectl apply -f https://storage.googleapis.com/tekton-releases/dashboard/latest/tekton-dashboard-release.yaml
Tekton Dashboard Install

By default, the Dashboard is not exposed outside the cluster. You need to deploy Ingress resource to access it. For quick start you can you kubectl proxy or port-forward method to get access on it.

$ kubectl proxy$ kubectl --namespace tekton-pipelines port-forward svc/tekton-dashboard 9097:9097

Once proxy or port-forward is set, access it via http url

# via proxy
http://localhost:8001/api/v1/namespaces/tekton-pipelines/services/tekton-dashboard:http/proxy/
# via port-forward
http://localhost:9097
Tekton Dashboard

You can create Tekton objects using Dashboard as well.

Is Tekton similar to OpenShift Pipelines?

OpenShift Pipelines is a CI/CD solution based on Tekton. These Pipelines are tightly integrated with OpenShift and Red Hat developer tools and is designed to run each step of the CI/CD pipeline in its own container.

That’s it for the post, I will come up with more advance topics on Tekton in coming weeks. Till then, Take care and Stay Safe.

Keep Learning !

How to Cleanup?

Uninstalling Dashboard

kubectl delete -f https://storage.googleapis.com/tekton-releases/dashboard/latest/tekton-dashboard-release.yaml

Uninstalling Tekton

kubectl delete -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

In quest of understanding How Systems Work !

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store