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.
- A
Build
can include multiplesteps
where each step specifies aBuilder
. - 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 aBuild
can push to a repository. - A
BuildTemplate
can be used to defined reusable templates. - The
source
in aBuild
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.
See the following reference topics for information about each of the build components:
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:
-
For details about installing a new instance of Knative in your Kubernetes cluster, see Installing Knative.
-
If you have a component of Knative installed and running, you can add and install the Knative Build component.
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']
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.
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.