# Tekton CI/CD Pipeline

> Tekton Pipelines for Kubernetes-native CI/CD.

- Category: DevOps & CI/CD
- Difficulty: advanced
- Components: tekton-pipelines, tekton-dashboard, registry
- Tags: tekton, cicd, kubernetes, pipelines
- Source: https://docker.recipes/devops/tekton-cicd-stack

## Overview

Tekton Pipelines is a Kubernetes-native CI/CD framework originally developed by Google and now maintained by the Continuous Delivery Foundation. It provides cloud-native pipeline execution using custom resource definitions (CRDs) that define reusable, declarative CI/CD workflows directly within Kubernetes clusters. Unlike traditional CI/CD tools that run as standalone services, Tekton leverages Kubernetes' native scheduling, scaling, and resource management capabilities to execute pipeline tasks as pods.

This stack combines Tekton Pipelines with a local Docker registry and KinD (Kubernetes in Docker) cluster to create a complete CI/CD development environment. The KinD cluster hosts the Tekton installation including the dashboard for visual pipeline management, while the Docker registry serves as a local image repository for build artifacts. This configuration eliminates external dependencies and provides a self-contained environment for developing, testing, and debugging Tekton pipelines before deploying to production Kubernetes clusters.

This setup is ideal for DevOps engineers learning Tekton, platform teams building internal CI/CD standards, and organizations wanting to prototype cloud-native pipelines without cloud infrastructure costs. The combination provides enterprise-grade pipeline capabilities with the convenience of local development, making it particularly valuable for teams transitioning from Jenkins or other traditional CI/CD tools to Kubernetes-native solutions.

## Features

- Tekton Dashboard web interface for visual pipeline monitoring and task execution tracking
- Cloud-native pipeline execution using Kubernetes pods with automatic resource cleanup
- Local Docker registry integration for storing and serving container images during builds
- KinD cluster providing full Kubernetes API compatibility for realistic pipeline testing
- Tekton Triggers support for webhook-based pipeline automation from Git repositories
- Custom Resource Definitions for defining reusable Tasks, Pipelines, and PipelineRuns
- Built-in workspace volume management for sharing data between pipeline steps
- RBAC integration using Kubernetes service accounts for secure pipeline execution

## Use cases

- Learning Tekton Pipelines syntax and concepts without requiring cloud Kubernetes clusters
- Developing and testing custom Tekton Tasks before deploying to production environments
- Prototyping multi-stage CI/CD workflows for containerized applications with local image builds
- Training development teams on cloud-native CI/CD practices using Kubernetes primitives
- Building internal platform engineering demos showcasing Tekton capabilities to stakeholders
- Testing Tekton Catalog tasks and community-contributed pipeline components locally
- Validating pipeline security policies and RBAC configurations in isolated environments

## Prerequisites

- Docker Desktop or Docker Engine with at least 8GB RAM allocated for KinD cluster operation
- kubectl CLI tool installed and configured for Kubernetes cluster management
- tkn CLI tool for creating and managing Tekton pipeline resources from command line
- Basic understanding of Kubernetes concepts including pods, services, and custom resources
- Familiarity with YAML syntax for writing Tekton Task and Pipeline definitions
- Local ports 5000, 6443, and 9097 available for registry, Kubernetes API, and dashboard access

## docker-compose.yml

```yaml
services:
  kind:
    image: kindest/node:v1.28.0
    container_name: tekton-cluster
    privileged: true
    ports:
      - "${API_PORT:-6443}:6443"
      - "${DASHBOARD_PORT:-9097}:30097"
    volumes:
      - kind_data:/var/lib/containerd

  registry:
    image: registry:2
    container_name: tekton-registry
    restart: unless-stopped
    ports:
      - "${REGISTRY_PORT:-5000}:5000"
    volumes:
      - registry_data:/var/lib/registry

volumes:
  kind_data:
  registry_data:
```

## .env

```bash
# Tekton CI/CD
API_PORT=6443
DASHBOARD_PORT=9097
REGISTRY_PORT=5000
```

## Usage notes

- Requires Docker privileged mode
- Tekton Dashboard at http://localhost:9097
- Local registry at localhost:5000
- Install tkn CLI for pipelines

## Troubleshooting

- Tekton Dashboard shows 'connection refused' errors: Verify KinD cluster is fully started and port 9097 is forwarded correctly to the dashboard service
- Pipeline runs fail with 'ImagePullBackOff' errors: Ensure images are pushed to localhost:5000 registry and cluster is configured to use insecure local registry
- Tasks timeout during execution: Increase resource limits in TaskRun specifications or allocate more memory to Docker Desktop
- KinD cluster fails to start: Check Docker has sufficient resources allocated and no other services are using port 6443
- Registry push operations fail with authentication errors: Configure Docker daemon to treat localhost:5000 as insecure registry in daemon.json
- Tekton webhooks not triggering pipelines: Verify Tekton Triggers are installed and EventListener services are exposed correctly

