Build is a custom resource in Knative that allows you to define a 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
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
More information about this use case is demonstrated in
Key features of Knative Builds
Buildcan include multiple
stepswhere each step specifies a
- 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.
Buildcan push to a registry.
BuildTemplatecan be used to defined reusable templates.
Buildcan be defined to mount data to a Kubernetes Volume, and supports:
- Google Cloud Storage
- An arbitrary container image
- Authenticate with
ServiceAccountusing Kubernetes Secrets.
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:
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.
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
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
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
If you are interested in contributing to the Knative Build project, see the Knative Build code repository.