Tekton is a powerful and flexible open-source framework for creating CI/CD systems, allowing developers to build, test, and deploy across cloud providers and on-premise systems.
Tekton is available as Kubernetes Custom Resource Definitions (CRD) that you can install in your Kubernetes cluster And it uses container images to perform operations in your CI/CD pipeline.
The main goal of Tekton is to provide a cloud-native standard set of building blocks for CI/CD systems to make it easier and faster to build, test, and package up your source code. It runs on Kubernetes and can target any platform, any language, and any cloud.
The Tekton project's vision is to create a set of composable, declarative, reproducible, and cloud-native components that can be used to develop robust pipelines. Because Tekton adds a set of Custom Resource Definitions (CRD), it is possible to reuse your pipelines or parts of those pipelines across multiple clouds.
What is Custom Resource Definitions (CRDS)
CRDs are an easy way to extend the Kubernetes API. Simply put, it is a way to create new objects that would extend the original Kubernetes scope. By creating those objects, it is possible to create software that runs directly inside Kubernetes, such as Tekton.
Tekton is an open source project, and you can find all the related code repositories under their GitHub organization at https://github.com/tektoncd
As mentioned earlier Tekton is a collection of CRDs, but it also includes many smaller projects such as the Tekton CLI, Triggers, Catalog, and Dashboard.
The Tekton project, at this moment, consists of 4 components:
- Pipelines: Basic building blocks (tasks and pipelines) of a CI/CD workflow
- Triggers: Event triggers for a CI/CD workflow
- CLI: Command-line interface for CI/CD workflow management
- Dashboard: General-purpose, web-based UI for Pipelines
As the name implies, Tekton provides a CLI, tkn, for easier interaction with Tekton components.This tool makes it easier to interact with Tekton components and is better than relying on kubectl. It is available as a binary executable for all major platforms, you may also build it from the source, or set it up as a kubectl plugin.
You can find the source code for this tool, in the Tekton GitHub repository at https://github.com/tektoncd/cli
This tool's installation instructions and usage will be shown in the next blog.
Tekton Triggers appeared as a child project of Tekton. It allows users to add a way to launch pipelines based on webhooks automatically. A use case for this would be to add your Tekton Trigger URL to your GitHub repository. This URL would be reached each time an event occurs. Events would include things such as code pushes.
Tekton Triggers will be covered in an upcoming blog.
The newest addition to the Tekton project is its Dashboard. Tekton Dashboard is a general-purpose, web-based UI for Tekton Pipelines, and Tekton triggers resources.
It allows users to manage and view Tekton resource creation, execution, and completion.
Among other things, the Tekton Dashboard supports:
- Filtering resources by label
- Real-time view of PipelineRun and TaskRun logs
- View resource details and YAML
- Show resources for the whole cluster or limit visibility to a particular namespace
- Import resources directly from a git repository
- Adding a functionality through extensions
Once it's been set up in your cluster, it will provide you with a web-based UI so that you can view and manage your Tekton components. It is built with React, and it can be installed directly into your Kubernetes cluster. You can find the source code for this project on GitHub at https://github.com/tektoncd/dashboard.
We are almost ready to get started with some hands-on examples of how to use Tekton, but before we do so, it is crucial to understand the basic building blocks that are used to build Tekton pipelines. There are not many components that can be used to build pipelines in Tekton, but they can all be parameterized and tweaked to build powerful pipelines.
Steps, tasks, and pipelines
The components you will be using the most when dealing with Tekton pipelines are steps, tasks, and pipelines. You can see the relationship between each of them in the following diagram:
image source: https://tekton.dev/docs/concepts/
A step is an operation in a CI/CD workflow, such as running some unit tests for a Python web app, or the compilation of a Java program. Tekton performs each step with a container image you provide. For example, you may use the official Go image to compile a Go program in the same manner as you would on your local workstation (go build).
A task is a collection of steps in order. Tekton runs a task in the form of a Kubernetes pod, where each step becomes a running container in the pod. This design allows you to set up a shared environment for a number of related steps; for example, you may mount a Kubernetes volume in a task, which will be accessible inside each step of the task.
A pipeline is a collection of tasks in order. Tekton collects all the tasks, connects them in a directed acyclic graph (DAG), and executes the graph in sequence. In other words, it creates a number of Kubernetes pods and ensures that each pod completes running successfully as desired.