Tekton Basics
Build cloud-native CI/CD pipelines using Tekton, the Kubernetes-native pipeline engine.
Time: ~15 minutes Difficulty: Intermediate
What You Will Learn
Section titled “What You Will Learn”- 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
Why Tekton
Section titled “Why Tekton”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.
Install Tekton
Section titled “Install Tekton”Navigate to the demo directory:
cd demos/tekton-basicskubectl apply -f manifests/namespace.yaml
# Install Tekton Pipelineskubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
# Wait for Tekton to be readykubectl get pods -n tekton-pipelines -wInstall the Tekton Dashboard (optional but recommended)
Section titled “Install the Tekton Dashboard (optional but recommended)”kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/latest/release.yaml
# Access the dashboardkubectl port-forward svc/tekton-dashboard -n tekton-pipelines 9097:9097Open http://localhost:9097.
Run a Simple Task
Section titled “Run a Simple Task”Create the Task
Section titled “Create the Task”kubectl apply -f manifests/task-hello.yamlRun it
Section titled “Run it”kubectl create -f manifests/taskrun-hello.yamlNote:
kubectl create(notapply) because the TaskRun usesgenerateNamefor unique names.
Check the result
Section titled “Check the result”# List TaskRunskubectl get taskruns -n tekton-demo
# Get logs from the latest runkubectl get taskruns -n tekton-demo -o name | tail -1 | \ xargs kubectl logs -n tekton-demo --all-containersYou should see: Hello, Tekton!
Run a Pipeline
Section titled “Run a Pipeline”A Pipeline chains multiple Tasks. This one clones a Git repo, lints the YAML files, and reports the results.
Create the Tasks and Pipeline
Section titled “Create the Tasks and Pipeline”kubectl apply -f manifests/task-git-info.yamlkubectl apply -f manifests/task-lint.yamlkubectl apply -f manifests/pipeline.yamlRun the Pipeline
Section titled “Run the Pipeline”kubectl create -f manifests/pipelinerun.yamlWatch it execute
Section titled “Watch it execute”# Watch pods spin up for each taskkubectl get pods -n tekton-demo -w
# Check the PipelineRun statuskubectl get pipelineruns -n tekton-demo
# Get logs from all taskskubectl get pipelineruns -n tekton-demo -o name | tail -1 | \ xargs kubectl logs -n tekton-demo --all-containers --prefixOr open the Tekton Dashboard at http://localhost:9097 to see the pipeline graph.
What is Happening
Section titled “What is Happening”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 pipelineTekton resource hierarchy:
Pipeline (defines the workflow) | v instantiated byPipelineRun (a single execution) | v createsTaskRun (one per Task in the Pipeline) | v createsPod (one per TaskRun, one container per Step)Key concepts in this demo:
| Concept | What It Does | Example |
|---|---|---|
params | Pass values into Tasks | name: "Tekton" |
workspaces | Share files between Tasks | PVC mounted in git-info and lint |
results | Pass small data between Tasks | Commit SHA from git-info to hello |
runAfter | Control execution order | lint runs after fetch-repo |
Experiment
Section titled “Experiment”-
Run the hello task with a different name:
Terminal window kubectl create -n tekton-demo -f - <<'EOF'apiVersion: tekton.dev/v1kind: TaskRunmetadata:generateName: hello-custom-spec:taskRef:name: helloparams:- name: namevalue: "Kubernetes"EOF -
List all TaskRuns and PipelineRuns:
Terminal window kubectl get taskruns,pipelineruns -n tekton-demo -
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
Cleanup
Section titled “Cleanup”kubectl delete namespace tekton-demo# Tekton system components remain installed for demo 31Further Reading
Section titled “Further Reading”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.
Next Step
Section titled “Next Step”Move on to Tekton CI/CD to build a real-world clone-test-build-deploy pipeline with triggers.