- Downloaded Tekton Operator v0.79.1 release manifest - Created TektonConfig CR enabling all components in innoventions namespace - Pipelines v1.13.0 with OCI bundles and custom tasks - Triggers v0.36.0 with stable API fields - Dashboard v0.69.0 with read-write access - Addon components (cluster tasks, templates) - Pruner configured (keep 100, daily at 2 AM) - Created Dashboard HTTPRoute for mission-space.local.mk-labs.cloud - Certificate via letsencrypt-prod ClusterIssuer - Routes via fastpass-gateway (Cilium Gateway API) - Backend: tekton-dashboard service port 9097 - Created ArgoCD Application manifest (wave 8) - Automated sync with prune/selfHeal - ServerSideApply for CRD compatibility - Ignore differences for operator-managed resources Directory: cluster/platform/tekton/ (functional naming) Namespace: innoventions (thematic naming) DNS: mission-space.local.mk-labs.cloud Ready for deployment to fastpass cluster.
4.7 KiB
Tekton Task Library
Reusable Tekton Tasks for common CI/CD operations across the mk-labs homelab.
Overview
Tasks are the building blocks of Tekton Pipelines. Each task defines a series of steps that execute in sequence within a container.
Key characteristics:
- Parameterized for flexibility
- Work with workspaces for file I/O
- Can be referenced by multiple pipelines
- Deployed to
innoventionsnamespace but usable across the cluster
Available Tasks
git-clone.yaml
Clone a Git repository from Gitea.
Parameters:
url- Git repository URL (e.g., https://gitea.mk-labs.cloud/rblundon/my-app.git)revision- Branch, tag, or commit SHA (default: main)subdirectory- Clone into subdirectory (default: "")
Workspaces:
output- Where the repository will be cloned
Usage:
tasks:
- name: fetch-source
taskRef:
name: git-clone
params:
- name: url
value: https://gitea.mk-labs.cloud/rblundon/my-app.git
- name: revision
value: main
workspaces:
- name: output
workspace: shared-workspace
kaniko-build.yaml
Build and push a container image using Kaniko (rootless builds).
Parameters:
image- Full image name including tag (e.g., the-seas.local.mk-labs.cloud/library/app:v1.0)context- Build context directory relative to workspace (default: .)dockerfile- Path to Dockerfile (default: ./Dockerfile)
Workspaces:
source- Source code containing Dockerfile
Secrets Required:
harbor-credentials- Docker config JSON for Harbor authentication
Usage:
tasks:
- name: build-image
taskRef:
name: kaniko-build
params:
- name: image
value: the-seas.local.mk-labs.cloud/library/my-app:v1.0
- name: dockerfile
value: ./Dockerfile
workspaces:
- name: source
workspace: shared-workspace
Testing Tasks Standalone
Each task can be tested independently before integrating into pipelines.
Example: Test git-clone
- Create test workspace:
kubectl apply -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-workspace
namespace: innoventions
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
storageClassName: nfs-emporium
EOF
- Run task:
tkn task start git-clone \
--param url=https://gitea.mk-labs.cloud/rblundon/homelab.git \
--param revision=main \
--workspace name=output,claimName=test-workspace \
--showlog \
--namespace innoventions
- Inspect result:
# Create debug pod
kubectl run -it --rm debug --image=busybox --restart=Never \
--overrides='{"spec":{"volumes":[{"name":"workspace","persistentVolumeClaim":{"claimName":"test-workspace"}}],"containers":[{"name":"debug","image":"busybox","stdin":true,"tty":true,"volumeMounts":[{"name":"workspace","mountPath":"/workspace"}]}]}}' \
-n innoventions -- sh
# Inside pod:
ls -la /workspace
Creating New Tasks
Follow the Tekton Task specification:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: my-task
namespace: innoventions
spec:
params:
- name: my-param
description: Parameter description
default: default-value
workspaces:
- name: my-workspace
description: Workspace description
steps:
- name: step-name
image: container-image:tag
script: |
#!/bin/sh
echo "Task logic here"
echo "Param value: $(params.my-param)"
ls $(workspaces.my-workspace.path)
Best practices:
- Pin container image versions (no
:latest) - Provide parameter defaults where sensible
- Document parameters and workspaces clearly
- Use script blocks for complex shell logic
- Test standalone before using in pipelines
Task Catalog Reference
Official Tekton task catalog: https://hub.tekton.dev/
Popular tasks to consider adding:
buildpacks- Build images without Dockerfilehelm-upgrade- Deploy Helm chartstrivy-scanner- Scan images for vulnerabilitiesgit-cli- Advanced Git operationspytest- Run Python tests
Installation from catalog:
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/TASK-NAME/VERSION/TASK-NAME.yaml
Version Management
All task image references should be pinned to specific versions.
Current image versions:
- Git init:
gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.43.0 - Kaniko:
gcr.io/kaniko-project/executor:v1.24.0
Update procedure:
- Check for new image releases
- Update task YAML with new version
- Test standalone
- Commit and deploy via ArgoCD
Location: cluster/tekton/tasks/
Deployed to: innoventions namespace
Owner: Platform Team