Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 98Tekton · Git and CI/CD

Install and set up Tekton (CI/CD inside Kubernetes)

Tekton runs CI/CD pipelines as Kubernetes resources: every step is a container in a Pod, pipelines are YAML in Git, and the cluster scales them. It is the engine behind OpenShift Pipelines and many internal platforms, and with Tekton Chains it can sign builds and create SLSA provenance. This guide installs Tekton Pipelines and the tkn CLI, writes Tasks and a Pipeline that clones, tests and builds an image with Buildah, runs it, and covers triggers, security and fixes.

  • 9 Lessen
  • 5 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

98.1

Know it before you install

A Task is a list of steps (containers) that run in one Pod. A Pipeline connects Tasks (order, parameters, results). A PipelineRun/TaskRun is one execution. Workspaces share files between Tasks (a PVC). Resolvers load Tasks from Git, bundles or the Artifact Hub catalog. Triggers start runs from webhooks.

ItemValue
Installrelease YAML from the Tekton docs (Pipelines, Triggers, Dashboard, Chains), or the Tekton Operator / OpenShift Pipelines
Namespacetekton-pipelines
CLItkn (from github.com/tektoncd/cli/releases, .rpm/.deb)
ObjectsTask, Pipeline, TaskRun, PipelineRun, EventListener, TriggerTemplate
Needsa Kubernetes cluster with a default StorageClass (for workspaces)

98.2

Install Tekton Pipelines and tkn

Apply the current release (check tekton.dev/docs/installation/pipelines for the download address of your version):

kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
kubectl -n tekton-pipelines get pods --watch
tekton-pipelines-controller-…   1/1   Running
tekton-pipelines-webhook-…      1/1   Running

The CLI (RHEL and Ubuntu) — the .rpm/.deb or the tarball from the tektoncd/cli releases:

TKNVER=0.42.0
curl -fsSLO https://github.com/tektoncd/cli/releases/download/v$TKNVER/tkn_${TKNVER}_Linux_x86_64.tar.gz
tar -xzf tkn_${TKNVER}_Linux_x86_64.tar.gz tkn
install -m 0755 tkn /usr/local/bin/tkn
tkn version

98.3

First configuration: a namespace, a service account, registry access

kubectl create namespace ci
kubectl -n ci create secret docker-registry harbor-push --docker-server=harbor.example.com --docker-username='robot$shop+ci' --docker-password='ROBOT_SECRET'
kubectl -n ci create serviceaccount pipeline
kubectl -n ci patch serviceaccount pipeline -p '{"secrets":[{"name":"harbor-push"}]}'

Pipelines run with this service account — give it only the rights the pipeline needs (no cluster-admin).

98.4

Tasks and a Pipeline

A Task that runs the tests:

tasks/run-tests.yaml
apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: run-tests
  namespace: ci
spec:
  workspaces:
    - name: source
  steps:
    - name: test
      image: docker.io/library/python:3.12-slim
      workingDir: $(workspaces.source.path)
      securityContext:
        runAsNonRoot: true
        runAsUser: 1000
      script: |
        pip install --user -r requirements.txt
        python -m pytest -q

The Pipeline: clone (catalog Task git-clone through the hub resolver) → test → build and push with Buildah (catalog Task buildah):

pipeline.yaml
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: shop-ci
  namespace: ci
spec:
  params:
    - name: repo-url
    - name: revision
      default: main
    - name: image
  workspaces:
    - name: shared
  tasks:
    - name: clone
      taskRef:
        resolver: hub
        params:
          - { name: kind, value: task }
          - { name: name, value: git-clone }
          - { name: version, value: "0.9" }
      params:
        - { name: url, value: $(params.repo-url) }
        - { name: revision, value: $(params.revision) }
      workspaces:
        - { name: output, workspace: shared }
    - name: test
      runAfter: [clone]
      taskRef:
        name: run-tests
      workspaces:
        - { name: source, workspace: shared }
    - name: build
      runAfter: [test]
      taskRef:
        resolver: hub
        params:
          - { name: kind, value: task }
          - { name: name, value: buildah }
          - { name: version, value: "0.9" }
      params:
        - { name: IMAGE, value: $(params.image) }
      workspaces:
        - { name: source, workspace: shared }
kubectl apply -f tasks/run-tests.yaml -f pipeline.yaml
tkn pipeline start shop-ci -n ci --serviceaccount pipeline -p repo-url=https://github.com/ORG/shop.git -p image=harbor.example.com/shop/api:$(date +%Y%m%d%H%M) -w name=shared,volumeClaimTemplateFile=pvc.yaml --showlog

(pvc.yaml is a small PersistentVolumeClaim template, for example 1 Gi ReadWriteOnce. Check the catalog Task versions you use and pin them.)

PartWhy
Workspace with volumeClaimTemplateEach run gets its own fresh volume, deleted with the run.
resolver: hub + versionReuse tested catalog Tasks, pinned to a version.
runAfterOrder between Tasks (others run in parallel).
Steps as non-rootPipelines are code from developers — they should not run as root in the cluster.

98.5

Daily use: the commands and the real uses

tkn pipelinerun list -n ci
tkn pipelinerun logs -f -n ci --last
tkn pipelinerun describe -n ci --last
tkn taskrun list -n ci
tkn pipeline list -n ci
tkn pipelinerun cancel shop-ci-run-x7k2p -n ci
tkn pipelinerun delete -n ci --keep 20

Add Tekton Triggers (an EventListener with a GitHub/GitLab interceptor) to start runs on push, the Dashboard for a web view, and Tekton Chains to sign images and attach SLSA provenance automatically.

Real uses at work:

  • CI/CD fully inside Kubernetes, scaling with the cluster (OpenShift Pipelines).
  • Platform teams offer standard pipelines; app teams run them with parameters.
  • Supply-chain security: signed images and provenance with Chains.

98.6

Make it safe

Security checklist:

  • A dedicated service account per pipeline with minimal RBAC; registry robot accounts, not personal logins.
  • No privileged steps: build with Buildah/kaniko without privileges; non-root steps; Pod Security on the ci namespace.
  • Pin catalog Tasks and step images (version or digest).
  • Triggers: verify webhook secrets (interceptors) — otherwise anyone can start pipelines.
  • Clean old runs (--keep, pruner) — they hold logs and volumes.
  • Chains for signed, traceable builds.

98.7

Update and remove

Apply the release YAML of the new version (read the upgrade notes: API versions change), then upgrade tkn. Remove: kubectl delete -f <the same release.yaml>.

98.8

Fix common problems

ProblemCauseFix
PipelineRun stays Pending: PVC not boundNo default StorageClass.Set a default StorageClass, or name one in the claim template.
unauthorized when pushing the imageThe service account has no registry secret.Link the docker-registry secret to the service account.
Resolver error: task not foundWrong name/version in the hub, or no internet from the cluster.Check the catalog; use a Git resolver or a bundle in your registry.
Step fails: permission deniedNon-root step writes to a root-owned path.Write to the workspace or $HOME; set fsGroup on the Pod template.
PipelineRun timed outDefault timeout (1 h) reached.Set timeouts.pipeline on the run; speed up steps (caches).
Admission webhook errors on applyTekton webhook Pod down.kubectl -n tekton-pipelines get pods; check its logs.

98.9

Next steps

1Where do the steps of a Tekton Task run?

As containers in one Kubernetes Pod per TaskRun.

2How do Tasks in a Pipeline share the cloned source code?

Through a workspace (for example a PVC from a volumeClaimTemplate).

Alle commando's in dit hoofdstuk