> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Tekton Pipelines

> Demo and tutorial showing how to use Tekton Pipelines to define Tasks and Pipelines, run TaskRuns and PipelineRuns, and visualize CI CD workflows in Kubernetes.

[Tekton](https://tekton.dev/docs/pipelines/) is a Kubernetes-native CI/CD system that runs entirely inside your cluster. Controllers, pipeline and task definitions, and their executions (TaskRuns and PipelineRuns) are Kubernetes custom resources — there is no separate external CI server to manage.

Key concepts:

| Resource | Purpose | Example |
| - | - | - |
| Task | A collection of sequential container steps (a single CI job) | `Task` that builds and tests an app |
| Pipeline | Composes Tasks and controls execution order | `Pipeline` that runs build then deploy |
| TaskRun / PipelineRun | Runtime instantiations that create pods and execute steps | `TaskRun` that executes a `Task` |

Useful links:

* [Tekton Pipelines docs](https://tekton.dev/docs/pipelines/)
* [Tekton CLI (tkn)](https://tekton.dev/docs/cli/)

Before creating Tasks and Pipelines, make sure Tekton Pipelines controllers and webhook are installed in the `tekton-pipelines` namespace and that you have a working `tkn` CLI. Also create the namespace you will use for your CI resources:

```bash theme={null}
kubectl create namespace ci-pipelines
```

## Verifying Tekton control plane

Check the Tekton Pipelines namespace to ensure the controllers and webhook pods are running:

```bash theme={null}
kubectl get pods -n tekton-pipelines
```

Example output:

```text theme={null}
NAME                                              READY   STATUS    RESTARTS   AGE
tekton-dashboard-7c54d984dd-r9jgv                 1/1     Running   0          31m
tekton-events-controller-5cbc777ccd-hd47v         1/1     Running   0          31m
tekton-pipelines-controller-65f567589b-lgv9v      1/1     Running   0          31m
tekton-pipelines-webhook-75cd84877-mfnkj          1/1     Running   0          31m
```

That minimal set (controllers + webhook — dashboard optional) is required to run Tekton pipelines in your cluster.

## Creating a minimal Task

Start with a simple `Task` that runs one step and prints a message. Save this as `hello-task.yaml`:

```yaml theme={null}
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello-task
  namespace: ci-pipelines
spec:
  steps:
    - name: say-hello
      image: alpine:3.18
      script: |
        echo "Hello from Kodekloud!"
```

Apply the Task and run a TaskRun using `tkn`:

```bash theme={null}
kubectl apply -f hello-task.yaml
tkn task start hello-task -n ci-pipelines --showlog
```

Example sequence and output:

```text theme={null}
task.tekton.dev/hello-task created
TaskRun started: hello-task-run-qqx4n
Waiting for logs to be available...
[say-hello] Hello from Kodekloud!
```

This demonstrates a TaskRun: the runtime object that spawned a pod to execute the Task's steps.

## Parameterizing a Task

Make the Task reusable by adding a parameter. Update `hello-task.yaml` to include a `message` parameter:

```yaml theme={null}
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello-task
  namespace: ci-pipelines
spec:
  params:
    - name: message
      type: string
      default: "Hello from Kodekloud!"
  steps:
    - name: say-hello
      image: alpine:3.18
      script: |
        echo "$(params.message)"
```

Apply the updated Task:

```bash theme={null}
kubectl apply -f hello-task.yaml
```

Start a TaskRun that uses the default parameter:

```bash theme={null}
tkn task start hello-task -n ci-pipelines --showlog
```

Output:

```text theme={null}
TaskRun started: hello-task-run-rz7jf
Waiting for logs to be available...
[say-hello] Hello from Kodekloud!
```

Pass a custom value using `-p`:

```bash theme={null}
tkn task start hello-task -n ci-pipelines -p message="Hello from Nourhan!" --showlog
```

Output:

```text theme={null}
TaskRun started: hello-task-run-lgkq9
Waiting for logs to be available...
[say-hello] Hello from Nourhan!
```

## A Task with multiple steps

Real CI jobs typically include multiple sequential steps (clone, build, test). Group related steps into one Task when appropriate — here is `build-task.yaml`:

```yaml theme={null}
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: build-task
  namespace: ci-pipelines
spec:
  params:
    - name: app-name
      type: string
  steps:
    - name: clone
      image: alpine:3.18
      script: |
        echo "Cloning repo for $(params.app-name)"
    - name: build
      image: alpine:3.18
      script: |
        echo "Building $(params.app-name)"
    - name: test
      image: python:3.11-alpine
      script: |
        echo "Running tests for $(params.app-name)"
```

Apply the Task:

```bash theme={null}
kubectl apply -f build-task.yaml
```

Start a TaskRun and pass the `app-name` parameter:

```bash theme={null}
tkn task start build-task -n ci-pipelines -p app-name="web-server" --showlog
```

Example output:

```text theme={null}
TaskRun started: build-task-run-sk277
Waiting for logs to be available...
[clone] Cloning repo for web-server
[build] Building web-server
[test] Running tests for web-server
```

Steps run sequentially (top to bottom) within a Task.

## Creating a deploy Task

Keep deployment logic separate as its own Task. Save as `deploy-task.yaml`:

```yaml theme={null}
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: deploy-task
  namespace: ci-pipelines
spec:
  params:
    - name: app-name
      type: string
    - name: environment
      type: string
      default: staging
  steps:
    - name: deploy
      image: alpine:3.18
      script: |
        echo "Deploying $(params.app-name) to $(params.environment)"
```

Apply the Task:

```bash theme={null}
kubectl apply -f deploy-task.yaml
```

## Wiring Tasks together with a Pipeline

Compose `build-task` and `deploy-task` into a `Pipeline` so they run in sequence. Save as `ci-pipeline.yaml`:

```yaml theme={null}
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: ci-pipeline
  namespace: ci-pipelines
spec:
  params:
    - name: app-name
      type: string
    - name: target-env
      type: string
      default: staging
  tasks:
    - name: build
      taskRef:
        name: build-task
      params:
        - name: app-name
          value: $(params.app-name)
    - name: deploy
      taskRef:
        name: deploy-task
      runAfter:
        - build
      params:
        - name: app-name
          value: $(params.app-name)
        - name: environment
          value: $(params.target-env)
```

Apply the Pipeline:

```bash theme={null}
kubectl apply -f ci-pipeline.yaml
```

Start a PipelineRun with parameters and follow logs:

```bash theme={null}
tkn pipeline start ci-pipeline -n ci-pipelines \
  -p app-name="web-server" \
  -p target-env="production" \
  --showlog
```

You should see the `build` TaskRun run its `clone`, `build`, `test` steps first, then the `deploy` TaskRun execute. Example condensed output:

```text theme={null}
PipelineRun started: ci-pipeline-run-xxxxx
Waiting for logs to be available...
[build | clone] Cloning repo for web-server
[build | build] Building web-server
[build | test] Running tests for web-server
[deploy | deploy] Deploying web-server to production
```

## Tekton Dashboard

Tekton provides a web dashboard where you can visualize Pipelines, PipelineRuns, Tasks, and TaskRuns. The dashboard lets you inspect logs, view parameters and statuses, and start runs from the UI.

![A dark-themed Tekton Dashboard screenshot showing the "About Tekton" page with a left navigation menu (Pipelines, Tasks, etc.), environment detail cards, and documentation/resource tiles. The top right features a stylized Tekton mascot graphic.](https://mintcdn.com/kodekloud-c4ac6d9a/8pYzlc1aD6cgTw8b/images/Prep-Course-Certified-Cloud-Native-Platform-Engineering-CNPE/GitOps-and-Continuous-Delivery/Demo-Tekton-Pipelines/tekton-dashboard-about-page-dark-theme.jpg?fit=max\&auto=format\&n=8pYzlc1aD6cgTw8b\&q=85\&s=c17f3a7fa7a2c5979951501096c6957c)

The Dashboard displays pipelines, pipeline runs, tasks, and TaskRuns — everything you can manage from the CLI is visible here.

![A screenshot of the Tekton Dashboard showing the Tasks page with three entries — build-task, deploy-task, and hello-task — all in the "ci-pipelines" namespace with their creation times. The left sidebar shows navigation items like Pipelines, PipelineRuns, StepActions, and Tasks.](https://mintcdn.com/kodekloud-c4ac6d9a/8pYzlc1aD6cgTw8b/images/Prep-Course-Certified-Cloud-Native-Platform-Engineering-CNPE/GitOps-and-Continuous-Delivery/Demo-Tekton-Pipelines/tekton-dashboard-tasks-ci-pipelines.jpg?fit=max\&auto=format\&n=8pYzlc1aD6cgTw8b\&q=85\&s=4aa4a86416f8f7945992047cd3179801)

You can click into runs to view logs, passed parameters, pod details, and more.

If your cluster uses strict RBAC or network policies, ensure the Tekton webhook and controllers have the required permissions. Webhook admission failures can prevent TaskRun and PipelineRun pods from being created.

## Summary

* Tasks group sequential steps executed in container images.
* Parameters make Tasks reusable and configurable.
* Pipelines compose Tasks and control ordering with `runAfter` and parameter/result wiring.
* TaskRuns and PipelineRuns are runtime objects that create pods and execute steps.
* The Tekton dashboard provides a visual interface to inspect and trigger runs.

References

* [Tekton Pipelines documentation](https://tekton.dev/docs/pipelines/)
* [Tekton CLI (tkn) documentation](https://tekton.dev/docs/cli/)
* [Tekton Dashboard](https://tekton.dev/docs/dashboard/)

> **[Watch Video](https://learn.kodekloud.com/user/courses/prep-course-certified-cloud-native-platform-engineer-cnpe/module/dff5382b-dbe7-4cac-bd2b-d5a47028945e/lesson/231fc569-3421-4ad0-9aa7-8c5fff348d7e)**

> **[Practice Lab](https://learn.kodekloud.com/user/courses/prep-course-certified-cloud-native-platform-engineer-cnpe/module/dff5382b-dbe7-4cac-bd2b-d5a47028945e/lesson/f963fc71-6121-47e8-89a4-681bf8bc36a8)**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.