Kahibaro
Discord Login Register

OpenShift Pipelines (Tekton)

Core Concepts of OpenShift Pipelines

OpenShift Pipelines is Red Hat’s Kubernetes‑native CI/CD solution based on Tekton. It lets you define build and delivery workflows as Kubernetes resources that run in the cluster, without relying on a centralized external CI server.

At a high level, OpenShift Pipelines provides:

You work with OpenShift Pipelines entirely through Kubernetes/OpenShift objects, not through a separate CI application UI.

Key differences from traditional CI tools:

Tekton Building Blocks

OpenShift Pipelines exposes Tekton concepts as Kubernetes resources. The most important ones:

Tasks and TaskRuns

A Task is a reusable unit of work. Each task defines one or more steps, and each step runs in a separate container.

Example use cases for tasks:

Conceptually:

A minimal Task might look like:

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: echo-hello
spec:
  steps:
    - name: say-hello
      image: registry.access.redhat.com/ubi9/ubi-minimal
      script: |
        echo "Hello from Tekton"

A corresponding TaskRun:

apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
  name: echo-hello-run
spec:
  taskRef:
    name: echo-hello

You normally won’t create TaskRuns manually very often; pipelines do that for you.

Pipelines and PipelineRuns

A Pipeline is an ordered composition of tasks, including dependencies between them.

Core concepts:

Example structure:

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: build-and-test
spec:
  params:
    - name: git-url
      type: string
  tasks:
    - name: fetch-source
      taskRef:
        name: git-clone
      params:
        - name: url
          value: $(params.git-url)
    - name: run-tests
      runAfter: [fetch-source]
      taskRef:
        name: maven-test

A PipelineRun triggers an instance of that pipeline:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: build-and-test-run
spec:
  pipelineRef:
    name: build-and-test
  params:
    - name: git-url
      value: https://github.com/example/repo.git

Each PipelineRun creates the necessary TaskRuns and pods to execute the workflow.

Workspaces, Params, and Results

These features connect tasks together:

Example snippets:

Triggers (High Level)

Tekton Triggers let you respond to events (mostly webhooks):

In OpenShift Pipelines, triggers are usually set up using resources like TriggerTemplate, TriggerBinding, and EventListener. These will be configured by cluster admins or DevOps engineers to integrate with Git providers or external systems.

OpenShift-Specific Integration

OpenShift Pipelines adds convenience and security integration on top of base Tekton.

Installation and Namespaces

Typically:

You use the same oc CLI and web console you already use for other OpenShift workloads.

Security, ServiceAccounts, and SCCs

Pipelines run using Kubernetes ServiceAccounts. This controls:

Typical patterns:

You often see configuration like:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: pipeline
secrets:
  - name: git-credentials
  - name: registry-credentials

Then reference it in PipelineRun.spec.serviceAccountName.

Integration with Image Streams and Builds

In OpenShift, application builds and images are often managed using ImageStreams. OpenShift Pipelines can:

Typical pattern:

  1. A Task checks out source code.
  2. Another Task builds and pushes an image to the internal registry.
  3. The pipeline updates a Deployment or a DeploymentConfig to use the new image, or simply relies on ImageStream triggers.

Defining a Simple Pipeline in OpenShift

Below is a conceptual walkthrough of creating a minimal OpenShift Pipeline that:

Details like actual build tools, languages, and deployment manifests will vary, but the structure is representative.

Example Tasks (High Level)

  1. Git clone task
    Uses a standard Tekton task (often from the Tekton catalog) to fetch source.

Key inputs:

  1. Build & push image task
    Uses tools such as buildah or s2i to build the image inside a container.

Key inputs:

Key outputs:

  1. Deploy task
    Applies Kubernetes/OpenShift manifests or patches an existing deployment.

Key inputs:

Example Pipeline Skeleton

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: build-and-deploy
spec:
  params:
    - name: git-url
      type: string
    - name: image-url
      type: string
  workspaces:
    - name: source
  tasks:
    - name: fetch-source
      taskRef:
        name: git-clone
      params:
        - name: url
          value: $(params.git-url)
      workspaces:
        - name: output
          workspace: source
    - name: build-image
      runAfter: [fetch-source]
      taskRef:
        name: buildah-build
      params:
        - name: IMAGE
          value: $(params.image-url)
      workspaces:
        - name: source
          workspace: source
    - name: deploy
      runAfter: [build-image]
      taskRef:
        name: deploy-using-oc
      params:
        - name: image
          value: $(params.image-url)

Then:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: build-and-deploy-run
spec:
  pipelineRef:
    name: build-and-deploy
  serviceAccountName: pipeline
  params:
    - name: git-url
      value: https://github.com/example/app.git
    - name: image-url
      value: image-registry.openshift-image-registry.svc:5000/myproject/app:latest
  workspaces:
    - name: source
      volumeClaimTemplate:
        spec:
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 1Gi

This example assumes relevant tasks (git-clone, buildah-build, deploy-using-oc) already exist in the namespace.

Working with OpenShift Pipelines in the Web Console

OpenShift adds pipeline‑focused views to the Developer Perspective in the web console:

You can:

This UI helps newcomers understand the flow of tasks without reading YAML.

Integrating with Git and External Systems

OpenShift Pipelines can be integrated with source control and other tools as part of a broader CI/CD setup:

Typical integration flow:

  1. A TriggerBinding extracts values (branch, repo URL, commit SHA) from the webhook payload.
  2. A TriggerTemplate maps those values into PipelineRun parameters.
  3. An EventListener exposes an HTTP endpoint; OpenShift networking exposes it externally.
  4. Git is configured to send webhooks to this endpoint.

Using the Tekton CLI (tkn)

In addition to oc, you can use the Tekton CLI (tkn) for pipeline operations (if installed):

This can be more convenient for developers working directly from the terminal.

Patterns and Best Practices Specific to OpenShift Pipelines

The following practices are particularly relevant when running Tekton on OpenShift:

Use the Developer Catalog and Sample Pipelines

OpenShift often provides prebuilt tasks and pipelines via:

These are useful starting points you can then customize.

Align Pipelines with OpenShift Environments

Typical patterns in OpenShift:

On OpenShift, this often leads to:

Manage Secrets Carefully

OpenShift Pipelines interact heavily with secrets:

Typical best practices:

Use Workspaces with OpenShift Storage

When using workspaces, OpenShift can back them with:

Choose based on:

On OpenShift, dynamic provisioning and storage classes are usually already configured by the platform team; pipelines can then request storage via PVC templates.

Where OpenShift Pipelines Fit in the Overall CI/CD Picture

Within a broader CI/CD practice on OpenShift:

In this context, OpenShift Pipelines (Tekton) give you:

Views: 12

Comments

Please login to add a comment.

Don't have an account? Register now!