Creating the Custom Builders in Tanzu Build Service (TBS)

Before we deep dive into the Builders creation process, let’s understand the basics of Builder and it’s usage in TBS.

What is a Builder?

A Builder is a container image that contains all the necessary components to run a build. Builder is created mainly by leveraging Buildpacks and Stack. There can be one or more Buildpacks in a Builder but the Stack can be just one.

Above diagram gives a pictorial view of the Builder creation. On the left hand side, you can see that there is a  Stack (combination of build and run image) and the set of ordered list of Buildpacks. On the right hand side, a Builder image is created by running the kp cli command that I will talk about a bit later.

There are two types of Builders:

  • Builders : Builders are Kubernetes namespace scoped resources
  • Cluster Builders : Cluster Builders are cluster scopeed resources

In my view, both do the same job except the difference in their scope. 

Pre-requirements for Creating a Builder

Before we begin creating a Builder, there are few pre-requirements that needs to be in place:

  • TBS is running and functional
  • kp cli is installed on a local system and it’s connectivity with Kubernetes cluster where TBS is running
  • A container registry with the permission to push the images
  • Admin permissions to manage TBS components like Clusterstack etc.
  • Secret for a container registry is created in a namespace where the Builder will be created

Steps for Creating a Builder

Creating a Builder is a very straightforward process if you have all the necessary pre-requirements in place. Below is the sample command for creating a Builder.

kp builder create <name> --tag <tag> --stack <stack> --store <store> --namespace <namespace> --buildpack <buildpack>

Let’s understand the parameters needed for the kp builder create command before we trigger it. 

  • <name> : Name of the Builder
  • <tag> : Builder image tag
  • <stack> : Name of the Stack used by the Builder 
  • <store> : Name of the Store used by the Builder
  • <namespace>: Kubernetes cluster namespace where you want the Builder to be available
  • <buildpack> : Name of the buildpack used by the Builder

Below is the list of commands that will be handy for you to fetch the required information needed by the “kp builder create” command.

List of available Cluster Stacks :  kp clusterstack list
List of available Cluster Store: kp clusterstore list
List of Cluster Builder : kp clusterbuilder list
List the Buildpacks in a specific Cluster Builder: kp clusterbuilder status <name of a clusterbuilder>

Now, I think there is enough info for us to create a Builder, Let’s trigger the Builder creation.

$ kp builder create go-builder002 --tag --stack base --store default --namespace spring --buildpack tanzu-buildpacks/go

Builder "go-builder002" created

– Validate the newly created Builder.

kp builder list -n spring
NAME                  READY    STACK                          IMAGE
demo-builder          false                                   
go-builder002         true     io.buildpacks.stacks.bionic    

– Validate the Builder image on a container registry.


In this post, I talked about a Builder creation pre-requirements, created and validated the Builder image. You can follow exactly similar methods for creating a Cluster Builder too with the difference to notice that the Cluster Builders are not namespace scoped but do exactly the same work with Builder. 

Now, you can use the newly created builder and create the image from go source code.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s