Take your function online using Knative Build Pipeline

Staffan Olsson
Staffan Olsson
Jan 3, 2019
Take your function online using Knative Build Pipeline
Take your function online using Knative Build Pipeline

In our previous post on Build Pipeline we showed how to migrate build templates to the new framework. Today Knative Serving v0.2.3 was released, which enables the full Source-to-URL workflow to make use of pipeline Tasks. In this post we’ll demonstrate how to launch your function code as a container using the new pipeline resource definitions.

As the release notes say you can replace the old Build part of Service resources with anything that “indicate completion via … type: Succeeded status: True | False | Unknown”. If you have a completed TaskRun somewhere, run kubectl describe on it and you’ll notice:

Status:
  Conditions:
    Last Transition Time:  2018-12-18T20:00:57Z
    Status:                True
    Type:                  Succeeded

Which means we should be good to go with Build Pipeline.

As with standalone use of Build Pipeline we first have to create the Task and its Resources. Let’s use an example from our triggermesh/pipeline-tasks repository. With that applied we can take a typical Service yaml and simply replace everything under “build:” with any TaskRun yaml (feel free to test it independently first). Our example then contains:

    configuration:
      build:
        apiVersion: pipeline.knative.dev/v1alpha1
        kind: TaskRun
        metadata:
          name: nodejs-riff
        spec:
          taskRef:
            name: nodejs-riff-build

Now let’s run this on a cluster where Knative Build isn’t even installed:

$ kubectl apply -f serving-build-example/service-build.yaml; kubectl get pods -w
service.serving.knative.dev/nodejs-riff created
NAME                           READY   STATUS    RESTARTS   AGE
nodejs-riff-00001-pod-dd98a5   0/1     Pending   0          0s
nodejs-riff-00001-pod-dd98a5   0/1   Pending   0     5s
nodejs-riff-00001-pod-dd98a5   0/1   Init:0/5   0     5s
...
nodejs-riff-00001-pod-dd98a5   0/1   Init:4/5   0     21s
nodejs-riff-00001-pod-dd98a5   0/1   PodInitializing   0     33s
nodejs-riff-00001-pod-dd98a5   0/1   Completed   0     34s
nodejs-riff-00001-deployment-589b784b6d-gfdwr   0/3   Pending   0     0s
...
nodejs-riff-00001-deployment-589b784b6d-gfdwr   3/3   Running   0     20s

Our function is now live! Used like this there’s no apparent advantage with Build Pipeline over the old Build, but in upcoming posts we’ll explore how to make use of the extended feature set. You could also set a watch on our pipeline-tasks repository to follow how examples evolve.

Related Posts

Join our newsletter

Subscribe to TriggerMesh newsletter. You'll get only the most important news about TriggerMesh