Joo's
반응형

Tekton Pipelines 설치

# Tekton Pipelines 최신 릴리스 설치
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

Tekton 설치 확인

# tekton-pipelines 네임스페이스 확인
kubectl get pods -n tekton-pipelines

# tekton CRD 확인
kubectl get crd | grep tekton

Tekton CLI(tkn) 설치 (로컬)

https://tekton.dev/docs/cli/

https://github.com/tektoncd/cli/releases/download/v0.42.0/tektoncd-cli-0.42.0_Linux-64bit.deb

# Replace LINK-TO-THE-PACKAGE with the package URL you would like to use.
curl -LO https://github.com/tektoncd/cli/releases/download/v0.42.0/tektoncd-cli-0.42.0_Linux-64bit.deb
sudo dpkg -i tektoncd-cli-0.42.0_Linux-64bit.deb

tkn version

Tekton Triggers 설치 → Git push 이벤트 같은 webhook으로 파이프라인 자동 실행

kubectl apply --filename https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml

Tekton Dashboard 설치 → 웹 UI

kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/latest/release.yaml

예제 Task 생성

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: hello
spec:
  steps:
    - name: echo
      image: alpine
      script: |
        #!/bin/sh
        echo "Hello Tekton!"
kubectl apply -f hello-task.yaml
tkn task start hello --showlog

# 아래처럼 [echo] Hello Tekton! 나와야 함.
ubuntu@master1:~/test-tekton$ tkn task start hello --showlog
TaskRun started: hello-run-2xpbb
Waiting for logs to be available...
[echo] Hello Tekton!

 

Tekton Pipelines를 설치한 네임스페이스(예: tekton-pipelines)는 **Tekton의 컨트롤 플레인 리소스(Controller, Webhook 등)**가 동작하는 공간입니다.
여기에 직접 Pipeline, Task, PipelineRun 같은 워크로드 리소스를 생성하면 관리 혼란이나 충돌이 발생할 수 있습니다.

권장 방식

  • Tekton 설치 네임스페이스: tekton-pipelines
    • Tekton 컨트롤러, webhook, CRD 동작 전용
  • 애플리케이션 빌드/배포용 네임스페이스: 예) test-tekton, ci, dev, prod
    • Pipeline, Task, PipelineRun, PVC 등 실제 파이프라인 실행 자원 배치
# Tekton이 설치된 네임스페이스
kubectl get pods -n tekton-pipelines  

# 테스트용 네임스페이스 만들기
kubectl create ns test-tekton

# (예시)내가 만든 워크로드 실행 네임스페이스
kubectl apply -f pipeline.yaml -n test-tekton

tekton pipeline에 cephFS로 만든 PVC를 연동하기

tekton에서 사용할 pvc 생성하기

storage class가 이미 만들어져 있어야 한다.

# storage class 확인
kubectl get sc

testuser@master1:~/tekton-test$ kubectl get sc
NAME                       PROVISIONER                     RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
rook-cephfs-storageclass   rook-ceph.cephfs.csi.ceph.com   Delete          Immediate           false                  9h

 

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: tekton-cache-pvc
  namespace: test-tekton # tekton-pipelines 이 네임스페이스는 쓰면 안됨.
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
  storageClassName: rook-cephfs-storageclass  # CephFS 기반 StorageClass
kubectl apply -f tekton-cache-pvc.yaml
kubectl -n test-tekton get pvc tekton-cache-pvc

 

Task -> Pipelines -> Pipelinesrun 순서대로 만든다.

 

1. Task (hello-cache-task.yaml)

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: hello-cache-task
  namespace: test-tekton
spec:
  workspaces:
    - name: cache-workspace
  steps:
    - name: write-message
      image: alpine
      script: |
        #!/bin/sh
        CACHE_FILE=$(workspaces.cache-workspace.path)/message.txt
        echo "Hello Tekton! $(date)" >> $CACHE_FILE
        echo "Message written to cache: $(cat $CACHE_FILE)"
    - name: read-message
      image: alpine
      script: |
        #!/bin/sh
        CACHE_FILE=$(workspaces.cache-workspace.path)/message.txt
        echo "Reading from cache:"
        cat $CACHE_FILE || echo "No cache found"
  • write-message : PVC에 메시지 기록
  • read-message : PVC에서 기존 메시지 읽기

2가지 step으로 task를 만든다. 첫번째 step은 pvc에 메시지를 기록하고, 두번째 step은 pvc에 기록된 메시지를 읽는다.

kubectl apply -f hello-cache-task.yaml

 

2. Pipeline (hello-cache-pipeline.yaml)

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: hello-cache-pipeline
  namespace: test-tekton
spec:
  workspaces:
    - name: shared-cache
  tasks:
    - name: hello-cache
      taskRef:
        name: hello-cache-task
      workspaces:
        - name: cache-workspace
          workspace: shared-cache
kubectl apply -f hello-cache-pipeline.yaml

task에서 사용할 workspace를 지정해준다.

 

3. PipelineRun (hello-cache-pipelinerun.yaml)

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: hello-cache-pipelinerun
  namespace: test-tekton
spec:
  pipelineRef:
    name: hello-cache-pipeline
  workspaces:
    - name: shared-cache
      persistentVolumeClaim:
        claimName: tekton-cache-pvc
kubectl apply -f hello-cache-pipelinerun.yaml

전체 실행 및 로그 확인

kubectl apply -f hello-cache-task.yaml
kubectl apply -f hello-cache-pipeline.yaml
kubectl apply -f hello-cache-pipelinerun.yaml

# PipelineRun 리스트 확인
tkn pipelinerun list -n test-tekton

# 로그 확인
tkn pipelinerun logs hello-cache-pipelinerun -f -n test-tekton

 

 

testuser@master1:~/tekton-test$ tkn pipelinerun logs hello-cache-pipelinerun -f -n test-tekton
[hello-cache : write-message] Message written to cache: Hello Tekton! Mon Sep 29 03:35:50 UTC 2025

[hello-cache : read-message] Reading from cache:
[hello-cache : read-message] Hello Tekton! Mon Sep 29 03:35:50 UTC 2025

 

pipelinerun을 삭제하고 다시 실행해보자.

# 이전에 실행한 pipelinerun 삭제
kubectl delete -f hello-cache-pipelinerun.yaml

# 다시 pipelinerun 실행
kubectl apply -f hello-cache-pipelinerun.yaml

이전에 실행했던 cache가 남아있다.

testuser@master1:~/tekton-test$ tkn pipelinerun logs hello-cache-pipelinerun -f -n test-tekton
[hello-cache : write-message] Message written to cache: Hello Tekton! Mon Sep 29 03:35:50 UTC 2025
[hello-cache : write-message] Hello Tekton! Mon Sep 29 03:38:57 UTC 2025

[hello-cache : read-message] Reading from cache:
[hello-cache : read-message] Hello Tekton! Mon Sep 29 03:35:50 UTC 2025
[hello-cache : read-message] Hello Tekton! Mon Sep 29 03:38:57 UTC 2025
반응형
profile

Joo's

@JooJY

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!