Getting Started with Tekton: Installation, Core Concepts, and a Sample CI Pipeline
This guide walks through installing Tekton on a Kubernetes cluster, explains its core CRD resources such as Task, TaskRun, Pipeline and PipelineResource, and demonstrates a complete example that clones a Go repository, runs tests, builds a Docker image, and pushes it to Docker Hub.
Tekton is a powerful, flexible open‑source cloud‑native CI/CD framework that originated from the Knative build‑pipeline project and now provides a standardized solution for building pipelines on Kubernetes.
Installation : With a running Kubernetes cluster (e.g., v1.16.2), Tekton can be installed by applying the official release YAML:
$ kubectl apply -f https://github.com/tektoncd/pipeline/releases/download/v0.12.0/release.yamlIf the default GCR images are unreachable, an alternative manifest that uses Docker Hub images can be applied:
$ kubectl apply -f https://raw.githubusercontent.com/cnych/qikqiak.com/master/data/manifests/tekton/release.yamlAfter installation, the tekton-pipelines namespace is created; verify the pods are running with kubectl get pods -n tekton-pipelines . Optionally, install the Tekton CLI via Homebrew on macOS:
$ brew tap tektoncd/tools
$ brew install tektoncd/tools/tektoncd-cliConfirm the CLI installation with tkn version .
Core Concepts : Tekton defines several CRDs:
Task – a template of steps to execute (e.g., compile, build, push).
TaskRun – an actual execution of a Task.
Pipeline – an ordered collection of Tasks and resources.
PipelineRun – an execution of a Pipeline.
PipelineResource – inputs or outputs for a Pipeline, such as a Git repo or a container image.
Example Walkthrough :
1. Create a Task that clones a Go repository and runs go test :
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: test
spec:
resources:
inputs:
- name: repo
type: git
steps:
- name: run-test
image: golang:1.14-alpine
workingDir: /workspace/repo
command: ["go"]
args: ["test"]Apply it with kubectl apply -f task-test.yaml .
2. Define a PipelineResource of type git pointing to the demo repository:
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: cnych-tekton-example
spec:
type: git
params:
- name: url
value: https://github.com/cnych/tekton-demo
- name: revision
value: masterApply it with kubectl apply -f pipelineresource.yaml .
3. Create a TaskRun that references the Task and the Git resource:
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: testrun
spec:
taskRef:
name: test
resources:
inputs:
- name: repo
resourceRef:
name: cnych-tekton-exampleApply with kubectl apply -f taskrun.yaml and monitor progress using kubectl get taskrun , kubectl get pods , or kubectl logs . When the pod reaches Completed , the TaskRun shows SUCCEEDED: True and the test output (e.g., PASS ) appears in the logs.
Alternatively, the Tekton CLI can start the Task and stream logs in one step:
$ tkn task start test --inputresource repo=cnych-tekton-example --showlogSummary : The article demonstrates installing Tekton on Kubernetes, defining a Task, PipelineResource, and TaskRun, executing the pipeline, and verifying results via kubectl and the Tekton CLI. The next steps would involve adding a Docker build task, pushing the image to Docker Hub, and chaining tasks into a full pipeline.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.