DEV Community

Srinivasaraju Tangella
Srinivasaraju Tangella

Posted on

Tekton for Beginners:Build Your First Kubernetes CI/CD Pipeline

End-to-End CI/CD Pipeline with Tekton

Hello World Example on Kubernetes

Modern cloud-native development requires automated pipelines to build, test, and deploy applications quickly and reliably. Continuous Integration and Continuous Deployment (CI/CD) pipelines eliminate manual steps, reduce errors, and accelerate software delivery.
In this tutorial, we will build a complete CI/CD pipeline using Tekton to deploy a simple Hello World application into Kubernetes.
By the end of this guide, you will understand how Kubernetes-native pipelines automate the application lifecycle.

What You Will Learn
In this tutorial we will cover:

• Introduction to Tekton
• CI/CD pipeline workflow
• Architecture design
• Installing required tools
• Building a sample application
• Writing Tekton Tasks
• Creating a Tekton Pipeline
• Running the pipeline
• Deploying to Kubernetes

1. Introduction to Tekton

Tekton is an open-source CI/CD framework designed for Kubernetes. It allows developers to define pipelines as Kubernetes resources.
Instead of using external CI servers, Tekton executes pipelines inside Kubernetes pods, making it scalable and cloud-native.
Tekton is part of the Cloud Native Computing Foundation (CNCF) ecosystem.

Key Characteristics

Tekton provides several important capabilities:
• Kubernetes-native pipeline execution
• Container-based task execution
• Highly modular pipeline design
• Reusable pipeline components
• Cloud-agnostic architecture
• GitOps-friendly workflows

2. Understanding Tekton Core Components
Tekton pipelines are composed of four main components.
Task
A Task represents a single unit of work.
Examples:
• Clone repository
• Build container image
• Run tests
• Deploy application
Pipeline

A Pipeline is a sequence of tasks that run in order.

Example pipeline:

Task 1 → Clone Code
Task 2 → Build Image
Task 3 → Deploy Application
PipelineRun
A PipelineRun triggers the execution of a pipeline.
It provides:
• Parameters
• Workspaces
• Runtime configuration
Workspace
A Workspace allows tasks to share files between pipeline steps.
Example:
Clone Task

Shared Workspace

Build Task

Deploy Task

3. CI/CD Workflow Overview

The pipeline we build follows this workflow:

Developer

│ git push

Git Repository


Tekton Pipeline

├── Clone Source Code

├── Build Docker Image

└── Deploy Application


Kubernetes Cluster
This automation eliminates manual deployment work

4. High-Level Architecture

Below is the full architecture of the CI/CD pipeline.

+------------------------------------------------+
| Developer |
| git push |
+----------------------+-------------------------+
|
v
+------------------------------------------------+
| Git Repository |
| (GitHub / GitLab) |
+----------------------+-------------------------+
|
v
+------------------------------------------------+
| Tekton |
| |
| Pipeline |
| ├── Task 1 : Clone Repository |
| ├── Task 2 : Build Container Image |
| └── Task 3 : Deploy Application |
| |
+----------------------+-------------------------+
|
v
+------------------------------------------------+
| Kubernetes Cluster |
| |
| Running Hello World Application |
| |
+------------------------------------------------+

5. Tools Required

Before starting, install the following tools in your system.
You need Kubernetes, which runs the containers and pipelines.
You also need kubectl, the command-line tool used to interact with Kubernetes clusters.
Docker is required to build container images.
Tekton Pipelines provides the CI/CD engine.
Tekton CLI (tkn) helps manage and monitor pipeline executions.
Finally, Git is needed to manage application source code.

6. Installing Kubernetes (Minikube)

For local testing we will use Minikube.

Download Minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Start the cluster:
minikube start

Verify the cluster:

kubectl get nodes
Expected output:

NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 2m v1.xx

7.Install Tekton Pipelines
Install Tekton into
Kubernetes.

kubectl apply --filename \
https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
Verify installation:

kubectl get pods -n tekton-pipelines
You should see Tekton controller pods running.

8. Install Tekton CLI
Install Tekton CLI.

sudo apt install -y tektoncd-cli
Verify installation.

tkn version

9. Sample Application
Our sample project structure looks like this.

hello-world

├── app.py
├── Dockerfile
└── deployment.yaml

10. Python Hello world

app.py
Python

from flask import Flask

app = Flask(name)

@app.route("/")
def hello():
return "Hello World from Tekton CI/CD!"

app.run(host="0.0.0.0", port=5000)

11. Dockerfile

This file builds the container image

FROM python:3.9

WORKDIR /app

COPY app.py .

RUN pip install flask

CMD ["python","app.py"]

12. Kubernetes Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: docker.io//hello-world:latest
ports:
- containerPort: 5000

13. Tekton Task – Clone Repository

apiVersion: tekton.dev/v1
kind: Task
metadata:
name: git-clone-task
spec:
params:

  • name: repo-url type: string workspaces:
  • name: output steps:
  • name: clone image: alpine/git script: | git clone $(params.repo-url) /workspace/output

14. Tekton Task – Build Image

apiVersion: tekton.dev/v1
kind: Task
metadata:
name: build-image-task
spec:
params:

  • name: image-name type: string workspaces:
  • name: source steps:
  • name: build image: docker workingDir: /workspace/source script: | docker build -t $(params.image-name) .

15. Tekton Task – Deploy Application

apiVersion: tekton.dev/v1
kind: Task
metadata:
name: deploy-task
spec:
params:

  • name: deployment-file type: string workspaces:
  • name: source steps:
  • name: deploy image: bitnami/kubectl workingDir: /workspace/source script: | kubectl apply -f $(params.deployment-file)

16. Tekton Pipeline

Clone Repo


Build Docker Image


Deploy Application
Pipeline YAML connects these tasks.

17. PipelineRun

PipelineRun triggers execution.
It defines:
• repository URL
• image name
• shared workspace

18. Run the Pipeline
Apply all Tekton resources.

kubectl apply -f task-clone.yaml
kubectl apply -f task-build.yaml
kubectl apply -f task-deploy.yaml
kubectl apply -f pipeline.yaml
kubectl apply -f pipelinerun.yaml
Enter fullscreen mode Exit fullscreen mode

19. Monitor Pipeline
View pipeline logs:
tkn pipelinerun logs -f

Check pipeline status:
kubectl get pipelineruns

20. Verify Deployment
Check running pods:

kubectl get pods
Forward port:
kubectl port-forward deployment/hello-world 8080:5000
Open browser:

http://localhost:8080

Expected output:

Hello World from Tekton CI/CD!

Final Pipeline Visualization

Developer


Git Push


Tekton Pipeline

├── Task 1
│ Clone Repository

├── Task 2
│ Build Docker Image

└── Task 3
Deploy Application


Kubernetes Cluster


Running Application
Benefits of Tekton
Tekton provides several advantages:
• Kubernetes-native CI/CD
• Modular and reusable tasks
• Container-based execution
• Scalable pipeline execution
• Cloud-agnostic architecture

Conclusion
Tekton enables teams to implement powerful CI/CD pipelines directly inside Kubernetes.
In this tutorial we built a pipeline that:
Clones source code
Builds a container image
Deploys the application to Kubernetes
This approach allows organizations to achieve fully automated cloud-native deployments.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)