Tekton은 Kubernetes 네이티브 CI/CD 파이프라인 프레임워크다. CRD(Custom Resource Definition)로 파이프라인을 정의하며 컨테이너 기반 스텝을 조합해 재사용 가능한 파이프라인을 구성한다.
핵심 리소스
| 리소스 | 설명 |
|---|
| Task | 단일 작업 단위 (순차적 스텝) |
| TaskRun | Task의 실행 인스턴스 |
| Pipeline | Task를 연결한 DAG 워크플로우 |
| PipelineRun | Pipeline의 실행 인스턴스 |
| Trigger | 이벤트 기반 자동 실행 |
Task 정의 예시
yaml
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: build-and-test
spec:
params:
- name: repo-url
type: string
- name: revision
type: string
default: main
workspaces:
- name: source
steps:
- name: clone
image: alpine/git:latest
script: |
git clone $(params.repo-url) $(workspaces.source.path)
cd $(workspaces.source.path)
git checkout $(params.revision)
- name: test
image: node:20-alpine
workingDir: $(workspaces.source.path)
script: |
npm ci
npm test
- name: build
image: node:20-alpine
workingDir: $(workspaces.source.path)
script: |
npm run build
Pipeline 정의
yaml
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: ci-pipeline
spec:
params:
- name: repo-url
- name: image-name
workspaces:
- name: shared-workspace
tasks:
- name: build-test
taskRef:
name: build-and-test
params:
- name: repo-url
value: $(params.repo-url)
workspaces:
- name: source
workspace: shared-workspace
- name: push-image
taskRef:
name: kaniko-build
runAfter: [build-test]
params:
- name: image
value: $(params.image-name)
workspaces:
- name: source
workspace: shared-workspace
관련 문서