1. Taskrun & Task
Task
TaskRun으로부터 특정 파라미터를 넘겨 받아서 문자열로 출력하는 Task를 배포하자
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: example
spec:
params:
- name: hong_string
type: string
default: "say hello"
- name: hong_default
default: "say_default"
- name: hong_array
type: array
default:
- " adasdas"
- " adasd22"
steps:
- name: saystring
image: ubuntu
command:
- echo
args:
- "$(params.hong_string)"
- "$(params.hong_array[*])"
- "$(params.hong_default)"
- Task를 위와 같이 작성하고, 배포하자. ubuntu 이미지를 통해 TaskRun에게 넘겨 받은 파라미터를 문자열로 출력하는 작업을 실행시킨다
- Task는 단순히 작업 템플릿이다. 이를 실행시킬려면 Taskrun이 필요하다
- 작업 ( STEP )은 실질적으로 컨테이너를 통해 실행한다. 작업을 위한 이미지를 통해 컨테이너를 배포하고, 해당 컨테이너에 작업과 관련된 명령과 명령 수행에 필요한 리소스를 주어 작업을 실행시키는 것이다. 작업을 완료하면, 해당 컨테이너는 종료된다
Taskrun
Task에 특정 파라미터를 넘겨서 실행하는 Taskrun을 배포하자
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: runexample
spec:
taskref:
name: example
params:
- name: hong_string
value: "this is hong string params"
- name: hong_array
value:
- "array1"
- "array2"
- "array3"
- Taskrun을 작성하자. 실행할 Task와 해당 Task에게 넘겨줄 파라미터들을 정의해야 한다
- Taskrun은 Task를 실행하는 오브젝트이다. 따라서 Task가 미리 준비되어 있어야 한다
- 실질적으로 작업을 실행하는 것은 TaskRun Pod이다. TaskRun을 배포하면, TaskRun Pod가 배포되어 Task에 명시된 작업을 실행한다
결과 확인

[ec2-user@ip-100-0-1-19 tektontest]$ k get task
NAME AGE
example 3m54s
[ec2-user@ip-100-0-1-19 tektontest]$ k get taskrun
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
runexample True Succeeded 2m9s 2m3s
[ec2-user@ip-100-0-1-19 tektontest]$ k get pod
NAME READY STATUS RESTARTS AGE
runexample-pod 0/1 Completed 0 2m19s
- Kubectl을 이용하여 확인하자
- task와 taskrun이 잘 배포되었으며, taskrun은 실행 결과, 이유, 실행 시간, 완료 시간을 확인할 수 이다
- taskrun을 배포하면, TaskRun Pod가 배포되어 작업을 수행한다. 해당 Pod 안에서 Step들은 각각 컨테이너로 동작하며, Step을 완료하면, 컨테이너 실행을 종료한다. 현대 Pod의 상태가 Completed이며, 동작 중인 컨테이너가 없는 것을 확인할 수 있다
[ec2-user@ip-100-0-1-19 tektontest]$ tkn task list
NAME DESCRIPTION AGE
example 8 minutes ago
[ec2-user@ip-100-0-1-19 tektontest]$ tkn taskrun list
NAME STARTED DURATION STATUS
runexample 6 minutes ago 6s Succeeded
- TEKTON CLI를 이용하여 task와 taskrun을 확인하자
- tkn을 사용하면, 작업을 수행하는데 소요된 시간을 확인할 수 있다
[ec2-user@ip-100-0-1-19 tektontest]$ tkn tr logs runexample
[saystring] this is hong string params array1 array2 array3 say_default
[ec2-user@ip-100-0-1-19 tektontest]$ tkn task logs example
this is hong string params array1 array2 array3 say_default
- log를 통해 작업 결과를 확인하자. logs 명령어를 통해 해당 작업의 결과를 확인할 수 있다
- taskrun의 경우, 실행한 task의 이름도 출력된다
- 파라미터를 잘 넘겨주었다!

- TEKTON Dashboard에서도 확인 가능하다
- Dashboard에서의 조작 역시, Kubeconfig와 함께 Kube Api Server에 명령을 내리는 방식이다
2. PipelineRun & Pipeline
Task
PipelineRun, Pipeline, Task를 사용해보자
- PipelineRun은 파이프라인을 실행시켜주는 오브젝트이기에 항상 맨 마지막에 배포해야 한다
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: example
spec:
params:
- name: hong_string
type: string
default: "say hello"
- name: hong_default
default: "say_default"
- name: hong_array
type: array
default:
- " adasdas"
- " adasd22"
steps:
- name: saystring
image: ubuntu
command:
- echo
args:
- "$(params.hong_string)"
- "$(params.hong_array[*])"
- "$(params.hong_default)"
- Task를 배포하자. Pipeline에게 넘겨 받을 파라미터를 정의하자
Pipeline
Task의 모음인 Pipeline을 정의하자
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: pipelineforexample
spec:
params:
- name: string_from_pprun
type: string
- name: array_from_pprun
type: array
tasks:
- name: task1
taskref:
name: example
params:
- name: hong_string
value: "$(params.string_from_pprun)"
- name: hong_array
value: "$(params.array_from_pprun[*])"
- Pipeline을 배포하자. PipelineRun에게 넘겨 받을 파라미터와 실행할 Task에게 넘겨줄 파라미터를 정의하자
- Pipeline은 Task의 모음이다. Pipeline에 포함될 Task들을 정의하자
PipelineRun
PipelineRun을 배포하면, 각 Task 마다 TaskRun이 자동으로 생성되기에 TaskRun을 따로 생성하지 않아도 된다
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: pipelinerunexample
spec:
pipelineRef:
name: pipelineforexample
params:
- name: string_from_pprun
value: "this is from pipelinerun string"
- name: array_from_pprun
value:
- "this is array1 from ppr"
- "this is array2 from ppr"
- PipelineRun을 배포하자. 실행할 Pipeline과 해당 Pipeline에게 넘겨줄 파라미터를 정의하자
결과 확인

[ec2-user@ip-100-0-1-19 tektontest]$ k get pr
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
pipelinerunexample True Succeeded 8s 2s
[ec2-user@ip-100-0-1-19 tektontest]$ k get pipeline
NAME AGE
pipelineforexample 17s
[ec2-user@ip-100-0-1-19 tektontest]$ k get taskrun
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
pipelinerunexample-task1 True Succeeded 2m33s 2m27s
[ec2-user@ip-100-0-1-19 tektontest]$ k get task
NAME AGE
example 26s
[ec2-user@ip-100-0-1-19 tektontest]$ tkn pr list
NAME STARTED DURATION STATUS
pipelinerunexample 20 seconds ago 6s Succeeded
[ec2-user@ip-100-0-1-19 tektontest]$ tkn pipeline list
NAME AGE LAST RUN STARTED DURATION STATUS
pipelineforexample 34 seconds ago pipelinerunexample 29 seconds ago 6s Succeeded
[ec2-user@ip-100-0-1-19 tektontest]$ tkn task list
NAME DESCRIPTION AGE
example 43 seconds ago
- 오브젝트들이 잘 배포되었는지 확인하자
- PipelineRun을 통해 Pipeline을 실행하면, 자동으로 각 Task를 실행시키는 TaskRun Pod가 생성된다. TaskRun의 이름은 자동으로 ' PipelineRun이름 + Pipeline에서 지정한 Task이름 ' 으로 지정된다

- PipelineRun 배포 시, TaskRun Pod가 자동 생성되어 작업을 수행한 것을 확인할 수 있다. 실질적인 작업 수행은 배포된 Task에 명시된 작업을 수행하는 TaskRun Pod이다
[ec2-user@ip-100-0-1-19 tektontest]$ tkn pr logs pipelinerunexample
[task1 : saystring] this is from pipelinerun string this is array1 from ppr this is array2 from ppr say_default
[ec2-user@ip-100-0-1-19 tektontest]$ tkn pipeline logs pipelineforexample
this is from pipelinerun string this is array1 from ppr this is array2 from ppr say_default
[ec2-user@ip-100-0-1-19 tektontest]$ tkn tr logs pipelinerunexample-task1
[saystring] this is from pipelinerun string this is array1 from ppr this is array2 from ppr say_default
[ec2-user@ip-100-0-1-19 tektontest]$ tkn task logs example
this is from pipelinerun string this is array1 from ppr this is array2 from ppr say_default
- log를 통해 작업 결과를 확인하자. 잘 실행되었다
- Pipeline이나 Task의 경우, 결과만 출력된다
- TaskRun은 결과 앞에 Step 이름이 출력된다
- PipelineRun은 결과 앞에 Pipeline에서 지정한 Task이름과 Step이름이 출력된다