# Migrating from Knative Build to Tekton Pipelines

Author: [Mete Atamel](https://atamel.dev/) | Published: 2019-08-28 | Updated: 2020-04-11 | Topics: Containers, Google Cloud, Kubernetes, Serverless | Canonical: https://atamel.dev/posts/2019/08-28_migrating-from-knative-build-to-tekton-pipelines/


![](/img/2019/1__O2nIYbl3W86S__PpyiuGQMw.png)

### Knative 0.8.0 and Build Deprecation

[Knative 0.8.0](https://github.com/knative/serving/releases/tag/v0.8.0) came out a couple of weeks ago with a number of fixes and improvements. One of the biggest changes in 0.8.0 is that Knative Build is now deprecated according to [docs](https://knative.dev/docs/build/):

![](/img/2019/0__7d371__EPwjXfyvQA.jpg)

Knative Installation docs also only include Knative Serving and Eventing without mentioning Build:

```sh
kubectl apply   
\-f https://github.com/knative/serving/releases/download/v0.8.0/serving.yaml \\  
\-f https://github.com/knative/eventing/releases/download/v0.8.0/release.yaml \\  
\-f https://github.com/knative/serving/releases/download/v0.8.0/monitoring.yaml
```

Good to know but there’s no explanation on why Knative Build was deprecated and any guidance on what is the replacement, if any. After a little bit of research, I have more information on deprecation and also a migration path that I’d like to share in this post.

There’s a Knative issue ( [614](https://github.com/knative/build/issues/614)) with more details but basically, it has been decided that building and pushing an image for a service should not be one of the core responsibilities for Knative.

Instead, Knative users can rely on a number of other better tools. One of those tools is called [Tekton Pipelines](https://github.com/tektoncd/pipeline). Inspired by Knative Build, The Tekton Pipelines project provides Kubernetes style resources for declaring CI/CD-style pipelines. It does everything Knative Build does and some more.

### Hello Tekton Pipelines

In [Tekton Pipelines](https://github.com/tektoncd/pipeline), you can create a simple one-off tasks or more complicated CI/CD pipelines. There are 4 main primitives for Tekton Pipelines:

* [Task](https://github.com/tektoncd/pipeline/blob/master/docs/tasks.md) defines the work that needs to be executed with 1 or more steps.
* [PipelineResources](https://github.com/tektoncd/pipeline/blob/master/docs/resources.md) defines the artifacts that can be passed in and out of a task.
* [TaskRun](https://github.com/tektoncd/pipeline/blob/master/docs/taskruns.md) runs the Task you defined with the supplied resources.
* [Pipeline](https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md) defines a list of tasks to execute in order.

Before you can use Tekton Pipelines, you need to install it in your Kubernetes cluster. Detailed [instructions](https://github.com/tektoncd/pipeline/blob/master/docs/install.md) are here but it’s as easy as:

```sh
kubectl apply -f [https://storage.googleapis.com/tekton-releases/latest/release.yaml](https://storage.googleapis.com/tekton-releases/latest/release.yaml)
```

Once you have it installed, you can check the Tekton pods:

### Knative Build ==> Tekton Pipelines

There’s basic documentation on [Migrating from Knative Build to Tekton.](https://github.com/tektoncd/pipeline/blob/master/docs/migrating-from-knative-build.md) In a nutshell, these are Tekton equivalents of Knative Build constructs:

![](/img/2019/1__yjEA9ETin1__8hmvL2jI2Cw.png)

Additionally, the [Tekton Catalog](https://github.com/tektoncd/catalog) aims to provide a catalog of re-usable Tasks, similar to what Knative BuildTemplate repository used to do before.

### Build with Kaniko Task

As an example, let’s take a look at how to build and push an image to Google Container Registry (GCR) using Tekton Pipelines.

In Tekton world, you start with either defining your custom Task ( [example](https://github.com/meteatamel/knative-tutorial/blob/master/docs/12-tekton-helloworldbuild.md#design-the-task)) or re-using someone else’s Task ( [example](https://github.com/meteatamel/knative-tutorial/blob/master/docs/14-tekton-kanikotaskbuild.md#install-kaniko-task)). Let’s use the [Kaniko Task](https://github.com/tektoncd/catalog/tree/master/kaniko) already available on Tekton Catalog.

First, install the Kaniko Task and make sure it’s installed:

```sh
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/kaniko/kaniko.yaml  
  
kubectl get task  
  
NAME     AGE  
kaniko   45m
```

Second, define a TaskRun to use the Task and supply the required parameters:

```sh
apiVersion: tekton.dev/v1alpha1  
kind: TaskRun  
metadata:  
  name: build-kaniko-helloworld-gcr  
spec:  
  taskRef:  
    name: kaniko  
  inputs:  
    resources:  
    - name: source  
      resourceSpec:  
        type: git  
        params:  
        - name: url  
          value: https://github.com/meteatamel/knative-tutorial  
    params:  
    - name: DOCKERFILE  
      value: Dockerfile  
    - name: CONTEXT  
      value: serving/helloworld/csharp  
  outputs:  
    resources:  
    - name: image  
      resourceSpec:  
        type: image  
        params:  
        - name: url  
          # Replace {PROJECT\_ID} with your GCP Project's ID.  
          value: gcr.io/{PROJECT\_ID}/helloworld:kaniko-tekton
```

Finally, start the TaskRun and check that it’s succeeded:

```sh
kubectl apply -f taskrun-build-kaniko-helloworld-gcr.yaml  
  
kubectl get taskrun  
  
NAME                          SUCCEEDED  
build-kaniko-helloworld-gcr   True
```

At this point, you should see the container image built and pushed to GCR.

Hopefully, this blog post provided you the basics needed to move from Knative Build to Tekton Pipeliens. I also updated my [Knative Tutorial](https://github.com/meteatamel/knative-tutorial) for the 0.8.0 release. Check it out for more examples of converting Knative Build to Tekton Pipelines:

![](/img/2019/0__rLfFkWMCfKccitnq.jpg)
