Tekton Pipelines
K8s-native CI/CD with Tasks, Pipelines, and Runs as CRDs.
CI/CDAdvanced
Why
Tekton is K8s-native CI/CD — Tasks and Pipelines are CRDs, runs are pods. It's cloud-native, extensible, and integrates with ArgoCD/Flux for GitOps.
DORA's 2024 State of DevOps report shows elite teams deploy 973x more frequently than low performers. CI/CD pipelines with automated testing reduce change failure rate to 5-15% versus 40-60% for manual deployments.
When
Use Tekton for K8s-native CI/CD. Avoid for non-K8s (use GH Actions).
How
1. Install — tekton-pipelines controller
2. Task — reusable step(s) in container
3. Pipeline — graph of Tasks
4. Resource — git input, image output
5. Run — PipelineRun triggers execution
6. Catalog — tekton catalog for reusable tasks
7. Trigger — event listener for webhooks
Example
# task.yaml — npm test
apiVersion: tekton.dev/v1beta1
kind: Task
metadata: { name: npm-test }
spec:
steps:
- image: node:20
script: |-
npm ci
npm test
# pipeline.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata: { name: ci }
spec:
tasks:
- name: test
taskRef: { name: npm-test }
- name: build
runAfter: [test]
taskRef: { name: npm-build }
# Run pipeline
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata: { name: ci-run }
spec: { pipelineRef: { name: ci } }
Common Problems
- ⚠Task fails — check pod logs, kubectl logs -n tekton-pipelines
- ⚠No git resource — use git-clone task from catalog
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use Tekton Catalog tasks — reusable, community-maintained
- ✓Use workspaces for shared storage — pass between tasks via PVC
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit