๐ง Tekton CI/CD Pipelines on AlmaLinux 9: Complete Guide
Ready to revolutionize your CI/CD with Kubernetes-native pipelines? ๐ Today weโll deploy Tekton on AlmaLinux 9, creating powerful, scalable pipelines that run as Kubernetes resources! Letโs build amazing automation! โจ๐ฏ
๐ค Why is Tekton Important?
Imagine CI/CD that scales infinitely with Kubernetes! ๐ Thatโs Tektonโs superpower! Hereโs why itโs revolutionary:
- ๐ฏ Kubernetes Native - Pipelines are first-class Kubernetes resources!
- ๐ฆ Reusable Components - Share tasks across teams and projects
- ๐ Infinite Scalability - Scale by adding Kubernetes nodes
- ๐ Event-Driven - Trigger pipelines from any event source
- ๐ ๏ธ Container-Based - Each step runs in its own container
- ๐ Built-in Observability - Monitor everything with Kubernetes tools
- ๐ Cloud Agnostic - Run anywhere Kubernetes runs
- ๐ก Declarative YAML - Define pipelines as code
๐ฏ What You Need
Before we build amazing pipelines, gather these:
- โ AlmaLinux 9 server (4GB RAM minimum, 8GB recommended)
- โ Kubernetes cluster 1.24+ (K3s, K8s, or any flavor)
- โ kubectl configured and working
- โ Git repository for pipeline code
- โ Container registry access (Docker Hub, Quay, etc.)
- โ Basic Kubernetes knowledge
- โ Root or sudo access
- โ Ready for pipeline magic! ๐
๐ Step 1: Prepare AlmaLinux Environment
Letโs prepare your system for Tekton! ๐ ๏ธ
Install Prerequisites
# Update system packages
sudo dnf update -y # Keep everything current
# Install essential tools
sudo dnf install -y git curl wget jq
# Verify Kubernetes cluster
kubectl get nodes # All should be Ready
kubectl version --short # Check version 1.24+
# Create tekton namespaces
kubectl create namespace tekton-pipelines
kubectl create namespace tekton-pipelines-resolvers
# Check available resources
kubectl top nodes # Ensure sufficient resources
Install Tekton CLI
# Download latest Tekton CLI (tkn)
TKN_VERSION="0.33.0" # Check for latest at github.com/tektoncd/cli
curl -LO https://github.com/tektoncd/cli/releases/download/v${TKN_VERSION}/tkn_${TKN_VERSION}_Linux_x86_64.tar.gz
# Extract and install
tar xvzf tkn_${TKN_VERSION}_Linux_x86_64.tar.gz
sudo mv tkn /usr/local/bin/
sudo chmod +x /usr/local/bin/tkn
# Verify installation
tkn version # Shows CLI version
# Enable bash completion
tkn completion bash | sudo tee /etc/bash_completion.d/tkn > /dev/null
source /etc/bash_completion.d/tkn
๐ง Step 2: Install Tekton Pipelines
Time to deploy Tektonโs core components! ๐
Method 1: Install with Operator (Recommended)
# Install Tekton Operator
kubectl apply -f https://storage.googleapis.com/tekton-releases/operator/latest/release.yaml
# Wait for operator to be ready
kubectl wait --for=condition=Ready pods -n tekton-operator --all --timeout=300s
# Create TektonConfig for complete installation
cat <<EOF | kubectl apply -f -
apiVersion: operator.tekton.dev/v1alpha1
kind: TektonConfig
metadata:
name: config
spec:
profile: all # Installs all components
targetNamespace: tekton-pipelines
pipeline:
enable-api-fields: beta
enable-custom-tasks: true
trigger:
enable-api-fields: beta
dashboard:
readonly: false
EOF
# Verify installation
kubectl get tektonconfig config
kubectl get pods -n tekton-pipelines # All should be Running
Method 2: Direct Installation
# Install Tekton Pipelines
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
# Install Tekton Triggers
kubectl apply --filename https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml
# Install Tekton Dashboard
kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/latest/release.yaml
# Monitor installation
kubectl get pods -n tekton-pipelines -w # Ctrl+C when all Running
# Verify components
tkn version # Shows all component versions
๐ Step 3: Create Your First Pipeline
Letโs build an amazing CI/CD pipeline! ๐
Create a Simple Task
# Create a Hello World task
cat <<EOF | kubectl apply -f -
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: hello-world
namespace: default
spec:
params:
- name: greeting
type: string
default: "Hello"
- name: name
type: string
default: "World"
steps:
- name: say-hello
image: alpine
command:
- echo
args:
- "\$(params.greeting), \$(params.name)! ๐"
- name: show-date
image: alpine
script: |
#!/bin/sh
echo "Current date: \$(date)"
echo "Running on AlmaLinux Kubernetes! ๐"
EOF
# Run the task
tkn task start hello-world \
--param greeting="Welcome" \
--param name="Tekton User" \
--showlog
# You'll see the output immediately!
Create a Build Pipeline
# Create a pipeline for building applications
cat <<EOF | kubectl apply -f -
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: build-and-deploy
namespace: default
spec:
params:
- name: git-url
type: string
description: Git repository URL
- name: git-revision
type: string
default: main
- name: image-name
type: string
description: Docker image name
workspaces:
- name: shared-workspace
- name: docker-credentials
tasks:
# Clone source code
- name: clone-source
taskRef:
name: git-clone
kind: ClusterTask
params:
- name: url
value: \$(params.git-url)
- name: revision
value: \$(params.git-revision)
workspaces:
- name: output
workspace: shared-workspace
# Run tests
- name: run-tests
runAfter: [clone-source]
taskRef:
name: npm-test
workspaces:
- name: source
workspace: shared-workspace
# Build container image
- name: build-image
runAfter: [run-tests]
taskRef:
name: buildah
kind: ClusterTask
params:
- name: IMAGE
value: \$(params.image-name)
workspaces:
- name: source
workspace: shared-workspace
- name: dockerconfig
workspace: docker-credentials
# Deploy to Kubernetes
- name: deploy
runAfter: [build-image]
taskRef:
name: kubernetes-actions
params:
- name: script
value: |
kubectl set image deployment/myapp myapp=\$(params.image-name)
kubectl rollout status deployment/myapp
EOF
# Install required ClusterTasks from Tekton Hub
tkn hub install task git-clone
tkn hub install task buildah
tkn hub install task kubernetes-actions
โ Step 4: Set Up Triggers
Letโs automate pipeline execution with triggers! ๐ฏ
Create EventListener
# Create trigger binding
cat <<EOF | kubectl apply -f -
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: github-push-binding
namespace: default
spec:
params:
- name: git-url
value: \$(body.repository.clone_url)
- name: git-revision
value: \$(body.after)
- name: git-repo-name
value: \$(body.repository.name)
EOF
# Create trigger template
cat <<EOF | kubectl apply -f -
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: github-push-template
namespace: default
spec:
params:
- name: git-url
- name: git-revision
- name: git-repo-name
resourcetemplates:
- apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: \$(tt.params.git-repo-name)-run-
spec:
pipelineRef:
name: build-and-deploy
params:
- name: git-url
value: \$(tt.params.git-url)
- name: git-revision
value: \$(tt.params.git-revision)
- name: image-name
value: "myregistry.io/\$(tt.params.git-repo-name):latest"
workspaces:
- name: shared-workspace
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
- name: docker-credentials
secret:
secretName: docker-credentials
EOF
# Create EventListener
cat <<EOF | kubectl apply -f -
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: github-listener
namespace: default
spec:
serviceAccountName: tekton-triggers-sa
triggers:
- name: github-push
bindings:
- ref: github-push-binding
template:
ref: github-push-template
EOF
# Expose EventListener
kubectl port-forward service/el-github-listener 8080:8080 &
echo "Webhook URL: http://localhost:8080"
๐ฎ Quick Examples
Letโs explore Tektonโs powerful features! ๐ฌ
Example 1: Parallel Task Execution
# Create pipeline with parallel tasks
cat <<EOF | kubectl apply -f -
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: parallel-pipeline
spec:
tasks:
- name: task-1
taskSpec:
steps:
- image: alpine
script: |
echo "Task 1 running! ๐"
sleep 5
echo "Task 1 done! โ
"
- name: task-2
taskSpec:
steps:
- image: alpine
script: |
echo "Task 2 running! ๐"
sleep 3
echo "Task 2 done! โ
"
- name: task-3
taskSpec:
steps:
- image: alpine
script: |
echo "Task 3 running! ๐"
sleep 4
echo "Task 3 done! โ
"
- name: final-task
runAfter: [task-1, task-2, task-3]
taskSpec:
steps:
- image: alpine
script: echo "All parallel tasks completed! ๐"
EOF
# Run the pipeline
tkn pipeline start parallel-pipeline --showlog
Example 2: Using Workspaces
# Create pipeline with workspace sharing
cat <<EOF | kubectl apply -f -
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: workspace-pipeline
spec:
workspaces:
- name: pipeline-ws
tasks:
- name: create-file
workspaces:
- name: output
workspace: pipeline-ws
taskSpec:
workspaces:
- name: output
steps:
- image: alpine
script: |
echo "Hello from Tekton! ๐" > \$(workspaces.output.path)/message.txt
echo "File created successfully!"
- name: read-file
runAfter: [create-file]
workspaces:
- name: input
workspace: pipeline-ws
taskSpec:
workspaces:
- name: input
steps:
- image: alpine
script: |
echo "Reading file content:"
cat \$(workspaces.input.path)/message.txt
EOF
# Run with PVC
tkn pipeline start workspace-pipeline \
--workspace name=pipeline-ws,claimName=tekton-pvc \
--showlog
Example 3: Tekton Dashboard
# Access Tekton Dashboard
kubectl port-forward -n tekton-pipelines service/tekton-dashboard 9097:9097 &
echo "๐จ Dashboard available at: http://localhost:9097"
# Browse to see all pipelines, tasks, and runs!
# Or use tkn to view resources
tkn pipeline list
tkn pipelinerun list
tkn taskrun list
๐จ Fix Common Problems
Donโt worry, weโve got solutions! ๐ช
Problem 1: Pipeline Fails to Start
# Check for RBAC issues
kubectl create serviceaccount pipeline-sa
kubectl create rolebinding pipeline-rb \
--clusterrole=edit \
--serviceaccount=default:pipeline-sa
# Use service account in PipelineRun
tkn pipeline start build-and-deploy \
--serviceaccount=pipeline-sa \
--showlog
# Check resource limits
kubectl describe limitrange -n default
kubectl describe resourcequota -n default
Problem 2: Task Not Found
# List available tasks
tkn task list
tkn clustertask list
# Install from Tekton Hub
tkn hub search git
tkn hub install task git-clone --version 0.9
# Create task if missing
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.9/git-clone.yaml
Problem 3: Workspace Issues
# Create PVC for workspace
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: tekton-workspace
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
EOF
# Use emptyDir for testing
tkn pipeline start my-pipeline \
--workspace name=shared-workspace,emptyDir="" \
--showlog
๐ Simple Commands Summary
Your Tekton command toolkit! ๐
Command | What It Does | When to Use |
---|---|---|
kubectl apply -f tekton-release.yaml | Install Tekton | Initial setup |
tkn pipeline start <name> | Run pipeline | Execute pipeline |
tkn pipeline list | List pipelines | View pipelines |
tkn pipelinerun logs <name> | View logs | Debug runs |
tkn task start <name> | Run single task | Test tasks |
tkn hub search | Search Tekton Hub | Find tasks |
tkn hub install task <name> | Install from Hub | Add tasks |
tkn pipeline describe <name> | Show pipeline details | Understand flow |
tkn pipelinerun cancel <name> | Cancel running pipeline | Stop execution |
kubectl get pods -n tekton-pipelines | Check Tekton pods | Verify health |
๐ก Tips for Success
Master Tekton with these pro tips! ๐
Pipeline Design
- ๐ฆ Keep tasks small and reusable
- ๐ Use workspaces for data sharing
- ๐ฏ Leverage Tekton Hub tasks
- ๐ Add resource limits to tasks
- ๐ Use secrets for credentials
Performance Optimization
- โก Run independent tasks in parallel
- ๐พ Cache dependencies in images
- ๐ Use persistent workspaces wisely
- ๐ Monitor resource usage
- ๐ฏ Optimize container images
Best Practices
- ๐ Version your pipeline definitions
- ๐ก๏ธ Implement proper RBAC
- ๐ Add comprehensive logging
- โ ๏ธ Set up monitoring and alerts
- ๐ Use GitOps for pipeline management
- ๐ Track metrics with Prometheus
- ๐จ Organize with namespaces
๐ What You Learned
Fantastic work! Youโre now a Tekton expert! ๐ You can:
- โ Install Tekton on AlmaLinux 9 Kubernetes
- โ Create tasks and pipelines
- โ Set up event-driven triggers
- โ Use workspaces for data sharing
- โ Run parallel task execution
- โ Access Tekton Dashboard
- โ Troubleshoot common issues
- โ Build production CI/CD pipelines
๐ฏ Why This Matters
Youโve built cloud-native CI/CD at its finest! ๐ With Tekton:
- Infinite Scale - Add nodes to scale pipelines
- True Kubernetes Native - Pipelines as K8s resources
- Reusable Components - Share tasks across teams
- Event-Driven - Automate everything with triggers
- Cloud Agnostic - Run anywhere Kubernetes runs
- GitOps Ready - Manage pipelines as code
- Cost Efficient - Pay only for what you use
Your CI/CD is now as scalable and resilient as your applications! No more Jenkins servers to maintain, no more pipeline bottlenecks. Everything runs as Kubernetes workloads!
Keep exploring advanced features like custom tasks, pipeline metrics, and integration with other tools. Youโre running modern CI/CD! ๐
Remember: Great software deserves great pipelines - Tekton delivers both! Happy building! ๐๐ง
P.S. - Join the Tekton community, contribute to Tekton Hub, and share your pipeline creations! The future of CI/CD is cloud-native! โญ๐