Skip to content

Tekton Basics

Build cloud-native CI/CD pipelines using Tekton, the Kubernetes-native pipeline engine.

Time: ~15 minutes Difficulty: Intermediate

  • Tasks: the building blocks (a sequence of steps running in a pod)
  • Pipelines: chaining Tasks together with dependencies
  • TaskRun and PipelineRun: executing Tasks and Pipelines
  • Parameters: passing values into Tasks
  • Workspaces: sharing files between Tasks
  • Results: passing data from one Task to the next
  • The Tekton Dashboard for visualizing runs

Tekton runs pipelines as Kubernetes resources. Each Task is a pod, each step is a container. This means:

  • Pipelines are declarative YAML, stored in Git, versioned like any other K8s resource
  • Each step runs in its own container (any image, any language)
  • Workspaces use PVCs, so data persists across steps and tasks
  • No external CI server needed (Jenkins, GitLab CI). The cluster IS the CI system.

Navigate to the demo directory:

Terminal window
cd demos/tekton-basics
Terminal window
kubectl apply -f manifests/namespace.yaml
# Install Tekton Pipelines
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
# Wait for Tekton to be ready
kubectl get pods -n tekton-pipelines -w
Section titled “Install the Tekton Dashboard (optional but recommended)”
Terminal window
kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/latest/release.yaml
# Access the dashboard
kubectl port-forward svc/tekton-dashboard -n tekton-pipelines 9097:9097

Open http://localhost:9097.

Terminal window
kubectl apply -f manifests/task-hello.yaml
Terminal window
kubectl create -f manifests/taskrun-hello.yaml

Note: kubectl create (not apply) because the TaskRun uses generateName for unique names.

Terminal window
# List TaskRuns
kubectl get taskruns -n tekton-demo
# Get logs from the latest run
kubectl get taskruns -n tekton-demo -o name | tail -1 | \
xargs kubectl logs -n tekton-demo --all-containers

You should see: Hello, Tekton!

A Pipeline chains multiple Tasks. This one clones a Git repo, lints the YAML files, and reports the results.

Terminal window
kubectl apply -f manifests/task-git-info.yaml
kubectl apply -f manifests/task-lint.yaml
kubectl apply -f manifests/pipeline.yaml
Terminal window
kubectl create -f manifests/pipelinerun.yaml
Terminal window
# Watch pods spin up for each task
kubectl get pods -n tekton-demo -w
# Check the PipelineRun status
kubectl get pipelineruns -n tekton-demo
# Get logs from all tasks
kubectl get pipelineruns -n tekton-demo -o name | tail -1 | \
xargs kubectl logs -n tekton-demo --all-containers --prefix

Or open the Tekton Dashboard at http://localhost:9097 to see the pipeline graph.

manifests/
namespace.yaml # tekton-demo namespace
task-hello.yaml # Simple greeting task (params)
task-git-info.yaml # Clone repo, extract commit SHA (workspaces, results)
task-lint.yaml # Lint YAML files (workspaces)
pipeline.yaml # Chain: git-info -> lint -> hello (runAfter, result refs)
taskrun-hello.yaml # Runs the hello task
pipelinerun.yaml # Runs the repo-check pipeline

Tekton resource hierarchy:

Pipeline (defines the workflow)
|
v instantiated by
PipelineRun (a single execution)
|
v creates
TaskRun (one per Task in the Pipeline)
|
v creates
Pod (one per TaskRun, one container per Step)

Key concepts in this demo:

ConceptWhat It DoesExample
paramsPass values into Tasksname: "Tekton"
workspacesShare files between TasksPVC mounted in git-info and lint
resultsPass small data between TasksCommit SHA from git-info to hello
runAfterControl execution orderlint runs after fetch-repo
  1. Run the hello task with a different name:

    Terminal window
    kubectl create -n tekton-demo -f - <<'EOF'
    apiVersion: tekton.dev/v1
    kind: TaskRun
    metadata:
    generateName: hello-custom-
    spec:
    taskRef:
    name: hello
    params:
    - name: name
    value: "Kubernetes"
    EOF
  2. List all TaskRuns and PipelineRuns:

    Terminal window
    kubectl get taskruns,pipelineruns -n tekton-demo
  3. Check the results from the git-info task:

    Terminal window
    kubectl get taskruns -n tekton-demo -l tekton.dev/pipeline=repo-check \
    -o jsonpath='{.items[0].status.results}' | python3 -m json.tool
Terminal window
kubectl delete namespace tekton-demo
# Tekton system components remain installed for demo 31

See docs/deep-dive.md for a detailed explanation of Tekton architecture, step containers, sidecar containers, timeout handling, retry policies, custom tasks, and Tekton Hub.

Move on to Tekton CI/CD to build a real-world clone-test-build-deploy pipeline with triggers.