Skip to content

Latest commit

 

History

History
 
 

build

Knative Build

A Build is a custom resource in Knative that allows you to define an process that runs to completion and can provide status. For example, fetch, build, and package your code by using a Knative Build that communicates whether the process succeeds.

A Knative Build runs on-cluster and is implemented by a Kubernetes Custom Resource Definition (CRD).

Given a Builder, or container image that you have created to perform a task or action, you can define a Knative Build through a single configuration file.

Also consider using a Knative Build to build the source code of your apps into container images, which you can then run on Knative serving. More information about this use case is demonstrated in this sample.

Key features of Knative Builds

  • A Build can include multiple steps where each step specifies a Builder.
  • A Builder is a type of container image that you create to accomplish any task, whether that's a single step in a process, or the whole process itself.
  • The steps in a Build can push to a repository.
  • A BuildTemplate can be used to defined reusable templates.
  • The source in a Build can be defined to mount data to a Kubernetes Volume, and supports:
    • git repositories
    • Google Cloud Storage
    • An arbitrary container image
  • Authenticate with ServiceAccount using Kubernetes Secrets.

Learn more

See the following reference topics for information about each of the build components:

Install the Knative Build component

Because all Knative components stand alone, you can decide which components to install. Knative Serving is not required to create and run builds.

Before you can run a Knative Build, you must install the Knative Build component in your Kubernetes cluster:

Configuration syntax example

Use the following example to understand the syntax and structure of the various components of a Knative Build. Note that not all elements of a Build configuration file are included in the following example but you can reference the Knative Build samples section along with the reference files above for more information.

The following example demonstrates a build that uses authentication and includes multiple steps and multiple repositories:

apiVersion: build.knative.dev/v1alpha1
kind: Build
metadata:
  name: example-build
spec:
  serviceAccountName: build-auth-example
  source:
    git:
      url: https://github.com/example/build-example.git
      revision: master
  steps:
  - name: ubuntu-example
    image: ubuntu
    args: ["ubuntu-build-example", "SECRETS-example.md"]
  steps:
  - image: gcr.io/example-builders/build-example
    args: ['echo', 'hello-example', 'build']

Get started with Knative Build samples

Use the following samples to learn how to configure your Knative Builds to perform simple tasks.

Tip: Review and reference multiple samples to piece together more complex builds.

Simple build samples

Build templates

Complex samples

Related info

If you are interested in contributing to the Knative Build project, see the Knative Build code repository.


Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.