liveBook · Manning

Pipeline

As explained in Platform Engineering on Kubernetes

A workflow is an organized sequence of activities and practices for accomplishing a software delivery or operational objective.

A pipeline is a repeatable sequence of tasks that produces an expected output. For cloud-native services, it automates work needed to build and run services, reducing the manual effort of adding or refactoring them. A pipeline definition describes the tasks; a pipeline engine creates an instance that executes them and reports their status. section 3.1

A pipeline can run tests, copy code, deploy software, provision virtual machines, or create users. Its steps depend on the objective, but the definition should be reusable so repeated executions can produce the same results. Organizations still need to choose tools and mature workflows around their own applications and operating constraints. section 3.1 section 1.1.2

Run a service pipeline with Tekton

A Tekton Pipeline sequences three tasks: fetch a file with a reusable wget task, read it with an inline cat task, and pass the content to a Hello World task. Install the wget task, then apply the Pipeline definition with kubectl apply -f hello-world-pipeline.yaml. Create and apply a separate PipelineRun for each execution. Use kubectl get taskrun to check task results and kubectl logs on the final task’s pod to inspect its output. section 3.5.2

Listing 3.6 Pipeline definition
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: hello-world-pipeline
  annotations:
    description: |
      Fetch resource from internet, cat content and then say hello
spec:
  results:                                            #1
  - name: message
    type: string
    value: $(tasks.cat.results.messageFromFile)
  params:                                             #2
  - name: url
    description: resource that we want to fetch
    type: string
    default: ""
  workspaces:                                         #3
  - name: files
  tasks:
  - name: wget
    taskRef:                                          #4
      name: wget
    params:
    - name: url
      value: "$(params.url)"
    - name: diroptions
      value:
        - "-P"  
    workspaces:
    - name: wget-workspace
      workspace: files
  - name: cat
    runAfter: [wget]
    workspaces:
    - name: wget-workspace
      workspace: files
    taskSpec:                                         #5
      workspaces:
      - name: wget-workspace
      results: 
        - name: messageFromFile
          description: the message obtained from the file
      steps:
      - name: cat
        image: bash:latest
        script: |
          #!/usr/bin/env bash
          cat $(workspaces.wget-workspace.path)/welcome.md | 
> kubectl get pods
NAME                                     READY   STATUS   AGE
tee /tekton/results/messageFromFile
  - name: hello-world
    runAfter: [cat]
    taskRef:
      name: hello-world-task                           #6
    params:
      - name: name
        value: "$(tasks.cat.results.messageFromFile)"  #7

The Tekton definition shows how parameters, a workspace, task references, and task ordering fit into one Pipeline resource. section 3.5.2

Pipelines can also process operational data rather than build services. A metrics pipeline collects events from multiple systems, transforms them into a standardized model, calculates DORA metrics, stores the results, and makes them available for a dashboard. Event sources must supply CloudEvents or be adapted to that format before entering this pipeline. section 9.2.2

How Platform Engineering on Kubernetes covers it

How deep it goes
Explains definitions, engine-run instances, and task status, then works through Tekton resources and commands.
Examples
Uses a Tekton file-fetching Pipeline with task-run output and a CloudEvents-based metrics collection pipeline.
What it assumes
Assumes a Kubernetes cluster with Tekton resources available; introduces pipeline definitions and engine-run instances before the example.
What you can do after
Apply it via Tekton to define and run a task sequence, then inspect its task runs and logs.
How it connects
Connects pipelines to cloud-native services, Tekton tasks, PipelineRuns, CloudEvents, CDEvents, and DORA metrics.

Also explained in

Compare how 48 books explain pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Platform Engineering on Kubernetes. The section links point to the parts of the book it draws on.