Knative Build to Tekton Task — Hello World
I am starting to learn Tekton and trying to compare it with Knative Build which I started learning early this year. Here is a simple Hello World example to compare both technology. The idea is to migrate to Tekton Pipeline and convert Build and BuildTemplate YAML to task, task run, pipeline, and pipeline resource YAML because Build and BuildTemplate are being deprecated.
A simple hello world example using Knative Build:
Apply build.yaml
kubectl apply -f build.yaml
build.build.knative.dev/echo-hello-world created
Build Pod
kubectl logs echo-hello-world-pod-1faec3 --all-containers{"level":"warn","ts":1560795916.6960523,"logger":"fallback-logger","caller":"logging/config.go:65","msg":"Fetch GitHub commit ID from kodata failed: \"ref: refs/heads/upstream/release-0.5\" is not a valid GitHub commit ID"}{"level":"info","ts":1560795916.6967626,"logger":"fallback-logger","caller":"creds-init/main.go:40","msg":"Credentials initialized."}hello worldBuild successful
Kubernetes Cluster Resource List
kubectl get allNAME READY STATUS RESTARTS AGE
pod/echo-hello-world-pod-1faec3 0/1 Completed 0 25mNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4d1hNAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
build.build.knative.dev/echo-hello-world True 25m
A simple hello world example using Tekton Task:
Apply task.yaml
kubectl apply -f task.yaml
task.tekton.dev/echo-hello-world created
Kubernetes Cluster Resource List
kubectl get allNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 4d1hNAME AGE
task.tekton.dev/echo-hello-world 15m
Apply task-run.yaml
kubectl apply -f task-run.yaml
taskrun.tekton.dev/echo-hello-world-task-run created
Kubernetes Cluster Resource List
kubectl get allNAME READY STATUS RESTARTS AGE
pod/echo-hello-world-task-run-pod-578741 0/2 Completed 0 29sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 94mNAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
taskrun.tekton.dev/echo-hello-world-task-run True 29s 10sNAME AGE
task.tekton.dev/echo-hello-world 22m
Task Run Pod
kubectl logs echo-hello-world-task-run-pod-578741 --all-containers{"level":"warn","ts":1560450406.5741897,"logger":"fallback-logger","caller":"logging/config.go:65","msg":"Fetch GitHub commit ID from kodata failed: \"ref: refs/heads/master\" is not a valid GitHub commit ID"}{"level":"info","ts":1560450406.574541,"logger":"fallback-logger","caller":"creds-init/main.go:40","msg":"Credentials initialized."}hello worldBuild successful
Knative Build vs Tekton Pipeline
Let’s look at some key differences in creating a hello world Knative build and hello world Tekton Task.
Difference 1: API Version and Kind of API are different (of course 😃)
Both build.yaml
and task.yaml
have similar semantics except the apiVersion and kind.
build.yaml:
apiVersion: build.knative.dev/v1alpha1
kind: Build
...
task.yaml:
apiVersion: tekton.dev/v1alpha1
kind: Task
...
Difference 2: Single Step vs Multi Step Process
Knative build defines the work that needs to be executed and runs it vs Task defines the work and TaskRun executes it.
Knative Build:
kubectl get allNAME READY STATUS RESTARTS AGE
pod/echo-hello-world-pod-1faec3 0/1 Completed 0 25mNAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
build.build.knative.dev/echo-hello-world True 25m
Task:
kubectl get allNAME AGE
task.tekton.dev/echo-hello-world 15m
Task Run:
kubectl get allNAME READY STATUS RESTARTS AGE
pod/echo-hello-world-task-run-pod-578741 0/2 Completed 0 29sNAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
taskrun.tekton.dev/echo-hello-world-task-run True 29s 10sNAME AGE
task.tekton.dev/echo-hello-world 22m
See you with one more comparison … 👍