3.6 KiB
3.6 KiB
CustomRun migration guide - Applicable to Tekton v0.43.x and greater.
CustomTask beta
Official TEP with full details
- Custom resource representing custom task feature in tektoncd is renamed from
RuntoCustomRuni.e.v1aplha1.Runis nowv1beta1.CustomRun. v1alpha1.Runis still supported by tekton and will be removed in future releases. Internallyv1alpha1.Runis converted to its correspondingv1beta1.CustomRun.
An example of a custom task Pipelineloop being converted from v1aplha1 API to v1beta1 API.
title
tab v1aplha1.Run API
---
apiVersion: custom.tekton.dev/v1alpha1
kind: PipelineLoop
metadata:
name: simpletaskloop
spec:
# Task to run (inline taskSpec also works)
pipelineRef:
name: demo-pipeline
# Parameter that contains the values to iterate
iterateParam: word
# Timeout (defaults to global default timeout, usually 1h00m; use "0" for no timeout)
timeout: 60s
---
apiVersion: tekton.dev/v1alpha1
kind: Run
metadata:
name: simpletasklooprun
spec:
params:
- name: word
value:
- jump
- land
- roll
- name: suffix
value: ing
ref:
apiVersion: custom.tekton.dev/v1alpha1
kind: PipelineLoop
name: simpletaskloop
tab v1beta1.CustomRun API.
---
apiVersion: custom.tekton.dev/v1alpha1
kind: PipelineLoop
metadata:
name: simpletaskloop
spec:
# Task to run (inline taskSpec also works)
pipelineRef:
name: demo-pipeline
# Parameter that contains the values to iterate
iterateParam: word
# Timeout (defaults to global default timeout, usually 1h00m; use "0" for no timeout)
timeout: 60s
---
apiVersion: tekton.dev/v1beta1
kind: CustomRun
metadata:
name: simpletasklooprun
spec:
params:
- name: word
value:
- jump
- land
- roll
- name: suffix
value: ing
customRef:
apiVersion: custom.tekton.dev/v1alpha1
kind: PipelineLoop
name: simpletaskloop
Custom task controller migration from v1aplha1.Run to v1beta1.CustomRun
- Upgrade the tekton version to v0.43.x or higher in project
go.mod, latest is better. - Perform
go mod tidyandgo mod vendorto upgrade the project to newer tekton version. - In the controller/reconciler code, start switching imports from
v1aplha1/runtov1beta1/customrun. As an example this has been done for PipelineLoop controller in this commit. - References are changed from
Run.Spec.ReftoCustomRun.Spec.CustomRef. - Pod Template field is now removed in
v1beta1.CustomRun. InPipelineLoopcontroller we are storing pod templates as field inside thePipelineLoopcustom resource. - We needed to convert the type(s) at one occasion thus wrote the following method:
// FromRunStatus converts a *v1alpha1.RunStatus into a corresponding *v1beta1.CustomRunStatus
func FromRunStatus(orig *v1alpha1.RunStatus) *customRun.CustomRunStatus {
crs := customRun.CustomRunStatus{
Status: orig.Status,
CustomRunStatusFields: customRun.CustomRunStatusFields{
StartTime: orig.StartTime,
CompletionTime: orig.CompletionTime,
ExtraFields: orig.ExtraFields,
},
}
for _, origRes := range orig.Results {
crs.Results = append(crs.Results, customRun.CustomRunResult{
Name: origRes.Name,
Value: origRes.Value,
})
}
for _, origRetryStatus := range orig.RetriesStatus {
crs.RetriesStatus = append(crs.RetriesStatus, customRun.FromRunStatus(origRetryStatus))
}
return &crs
}