Codenamed build-v2
An API to build container-images on Kubernetes using popular strategies and tools like
source-to-image
, buildpack-v3
, kaniko
, jib
and buildah
, in an extensible way.
The following are the BuildStrategies
supported by this operator, out-of-the-box:
Users have the option to define their own(custom) BuildStrategies
and make them available for consumption
by Builds
.
This operator ships two CRDs in order to register a strategy and then start the actual application builds using a registered strategy.
- The resource
BuildStrategy
(buildstrategies.build.dev/v1alpha1
) allows you to define a shared group of steps needed to fullfil the application build in namespaced scope. Those steps are defined ascontainers/v1
entries.
apiVersion: build.dev/v1alpha1
kind: BuildStrategy
metadata:
name: source-to-image
spec:
buildSteps:
...
The secret can be created like kubectl create secret generic <SECRET-NAME> --from-file=.dockerconfigjson=<PATH/TO/.docker/config.json> --type=kubernetes.io/dockerconfigjson
- The resource
ClusterBuildStrategy
(clusterbuildstrategies.build.dev/v1alpha1
) allows you to define a shared group of steps needed to fullfil the application build in cluster scope. Those steps are defined ascontainers/v1
entries.
apiVersion: build.dev/v1alpha1
kind: ClusterBuildStrategy
metadata:
name: source-to-image
spec:
buildSteps:
...
Well-known strategies can be boostrapped from here.
The resource Build
(builds.dev/v1alpha1
) binds together source-code and BuildStrategy
and related configuration as the build definition
Please consider the following example:
apiVersion: build.dev/v1alpha1
kind: Build
metadata:
name: buildpack-nodejs-build
spec:
source:
url: https://github.com/sclorg/nodejs-ex
credentials:
name: source-repository-credentials
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
builder:
image: heroku/buildpacks:18
credentials:
name: builder-registry-credentials
output:
image: quay.io/olemefer/nodejs-ex:v1
credentials:
name: output-registry-credentials
The resource BuildRun
(buildruns.dev/v1alpha1
) is the build process of a build definition which is executed in Kubernetes.
Please consider the following example:
apiVersion: build.dev/v1alpha1
kind: BuildRun
metadata:
name: buildpack-nodejs-buildrun
spec:
buildRef:
name: buildpack-nodejs-build
The BuildRun resource is updated as soon as the current building status changes:
$ kubectl get buildruns.build.dev buildpack-nodejs-buildrun
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
buildpack-nodejs-buildrun Unknown Running 70s
And finally:
$ kubectl get buildruns.build.dev buildpack-nodejs-buildrun
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
buildpack-nodejs-buildrun True Succeeded 2m10s 74s
Examples of Build
resource using the example strategies shipped with this operator.
-
Install Tekton, optionally you could use OpenShift Pipelines Community Operator
-
Install operator-sdk
-
Create a project or namespace called build-examples by using
kubectl create namespace build-examples
-
Execute
make local
to register well-known build strategies including Kaniko and start the operator. -
Create a Kaniko build
apiVersion: build.dev/v1alpha1
kind: Build
metadata:
name: kaniko-golang-build
namespace: build-examples
spec:
source:
url: https://github.com/sbose78/taxi
strategy:
name: kaniko
kind: ClusterBuildStrategy
dockerfile: Dockerfile
pathContext: ./
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
- Start a Kaniko buildrun
apiVersion: build.dev/v1alpha1
kind: BuildRun
metadata:
name: kaniko-golang-buildrun
namespace: build-examples
spec:
buildRef:
name: kaniko-golang-build
- Build, test & run using HACK.md.
Build Strategy | Alpha | Beta | GA |
---|---|---|---|
Source-to-Image | ☑ | ||
Buildpacks-v3 | ☑️ | ||
Kaniko | ☑️ | ||
Buildah | ☑️ |
Feature | Alpha | Beta | GA |
---|---|---|---|
Private Git Repos | ☑️ | ||
Private Output Image Registry | ☑️ | ||
Private Builder Image Registry | ☑️ | ||
Cluster scope BuildStrategy | ☑️ | ||
Runtime Base Image | ⚪️ | ||
Binary builds | |||
Image Caching | |||
ImageStreams support | |||
Entitlements |