Skip to content

4.2. Building From the Console

When to Use It

  • When you want to turn source code into a container image without writing a Dockerfile
  • When you want to run a build from a screen and deploy the result right away
  • When the application is simple and does not need a Jenkins pipeline

If you need repeated runs or a deployment approval process, use Jenkins (see 4.4).

The Relationship Between a Build Config and a Build

Two things need to be distinguished.

NameWhat it isIn concrete terms
Build config (BuildConfig)A reusable template holding "what to build and how"A configuration resource stored in the cluster
BuildOne execution of that configA Job running in the cluster

Once you create a build config, you only have to select Start build whenever the source changes. Each run creates a new build and accumulates as history.

The build config by itself does nothing. It is only stored, and the work is created from its contents when you run it.

The Build Config List

Go to Build > Build Configs.

Build config list
ColumnDescription
NameThe build config name
Git URLThe repository the source comes from
Builder imageThe image responsible for compilation
Output imageThe name of the image to be created
AgeTime elapsed since creation

If the list is empty, a guidance message appears with a Create build config button. This is the first screen you see, so start there.

On clusters where the build feature is not installed, a guidance banner appears instead of the list. Ask operations staff to install the build feature.

Creating a Build Config — Four Tabs

Selecting Create at the top right of the list opens a window with four tabs.

TabDescriptionWhen to use it
Guided editorA dedicated input form for build configsThe default. Enough for most cases
YAML editorEnter the configuration directly as YAMLWhen copying another configuration over
Form editorEvery field in an automatically generated formWhen you need a field the guided editor lacks
API documentationA description of each fieldWhen you want to know what a field means

In the guided editor you choose Secrets, volumes, and builder images from dropdowns. Because you do not type names yourself, failures from typos are reduced.

Guided Editor Fields

FieldDescriptionExample
NameThe build config name. Must be unique within the namespaceegov-build
NamespaceWhere the build runs and its result is placedegov
Git URLThe repository holding the sourcehttp://gitlab.../egov.git
Branch or tagThe point to fetch. Empty means the default branchmain
SubdirectoryThe path inside the repository to buildbackend
Source credentialsThe Secret to use for a private repositorygitlab-cred
Builder imageThe image matching the language and build toolSelect from the dropdown
Builder credentialsThe Secret for pulling the builder imageharbor-cred
Build environment variablesValues used during compilationMAVEN_ARGS, MAVEN_MIRROR_URL
Output imageThe address of the image to be createdharbor.../egov:latest
Push credentialsThe Secret for pushing to the registryharbor-cred
Tag policySee "Image Tag Rules" belowGitRef

Only builders registered in the cluster appear in the builder image list. Commonly used languages such as Java, Node.js, and Python are prepared. If the builder you need is absent, ask operations staff to register it or use the Jenkins or Bastion route (chapters 4.4 and 4.5).

A default is filled in for the output image address. If a default registry is configured on the cluster, it is pre-filled in the form <registry>/apps/... and you change only the ... part.

In environments using an internal library repository (Nexus), you have to add the MAVEN_MIRROR_URL environment variable to fetch dependency libraries. Air-gapped environments cannot reach external repositories.

Image Tag Rules

The tag written in the output image is a base value, and the actual tag is decided by the tag policy.

Tag policyTag producedCharacteristic
GitRef (default)<branch>-<7-character commit hash>The tag alone tells you which source it was built from
Unique<time>-<4 random characters>Always different on every run

Both policies produce a different tag on every run, so deploying definitely brings up a new version. Pinning the tag to latest leaves the image address unchanged, which causes the problem of pods not changing on deployment; COP prevents that this way.

With GitRef, rebuilding the same commit produces the same tag. In that case, deploying triggers no rollout. If you need to deploy again without changing the source, use Unique.

Build Resource Settings

A build runs as a pod inside the cluster. Resource requests and limits are always filled in.

FieldDefault
Requested CPU500m
Requested memory1Gi
Requested ephemeral storage4Gi
CPU limit2
Memory limit4Gi

There is a reason the defaults are not left empty. A pod with no resource requests falls into the first-to-be-evicted grade (BestEffort; see chapter 3.1), and the build could consume node memory to the end and take other pods down with it.

If a large project runs short of memory, raise the limit. Conversely, if the limit exceeds the namespace resource quota, the build does not start (see 8.1).

Reducing Build Time With a Cache

Maven and Gradle take a long time if libraries are fetched anew every time. Attaching storage (a PVC) at the cache path makes subsequent builds faster.

Choose a PVC in the volume section of the guided editor and specify the mount path.

Build toolCache path
Maven/home/jboss/.m2 (may differ by builder image)
Gradle~/.gradle
npm~/.npm

The PVC has to be created first before it appears in the list (see 6.1).

What Is Created Alongside

Creating a build config also creates a deployment skeleton (a Deployment). Its replica count is 0, so no pods start.

The reason is that starting a pod while no image exists yet produces repeated ImagePullBackOff errors because the image cannot be pulled. It goes from 0 to 1 on the first deployment.

A Service is not created at this point. Which port to open can only be known after the build finishes.

Running and Cancelling a Build

The buttons are grouped on the build config detail screen.

ButtonWhat it does
Start buildRuns a new build with the current configuration
Cancel buildAborts the build in progress
RebuildCancels what is in progress and starts anew
DeployDeploys the image from the last successful build

Two builds of the same build config cannot run at the same time. While one is in progress, the start button is disabled.

The lower part of the detail screen shows the history of builds run with this config. Along with name, status, and start time, it shows which node it ran on, so you can tell here if it fails only on a particular node.

Build history keeps 20 entries by default, and the oldest are deleted.

Deploying

The Deploy button deploys the image from the last successful build.

It behaves as follows.

SituationBehavior
The deployment target already existsSwaps the container image and does a rolling update
The deployment target does not existCreates it (1 replica)
Replicas are 0Swaps the image and raises it to 1
The image has an EXPOSE port and there is no ServiceCreates a ClusterIP Service, once only

When swapping the image, a confirmation window appears showing the image before and the image after. Check how the tag changes before proceeding.

The deploy button is disabled if the image is already deployed. Deploying the same image again changes nothing. It stays enabled when replicas are 0, however, because turning it on is still an action.

Existing Services are never overwritten. To change a port, edit the Service directly (see 5.1).

What to Check When It Fails

SymptomCauseRemedy
Cannot fetch the sourceWrong repository URL or branch, missing credentials for a private repositoryCheck the URL and branch, specify a source credential Secret
Compilation failureAn error in the source itself, dependency libraries not fetchedThe error line in the build log, check MAVEN_MIRROR_URL
Image push failure (UNAUTHORIZED)Missing registry credentials or insufficient permissionCheck the account and password in the push Secret and the permissions on that project
Certificate errorA registry with a private certificateCheck the insecure connection option in the build config
The build does not startNot enough resources for the buildCheck the namespace resource quota (see 8.1)
Aborted due to insufficient memoryThe build needs more memory than the limitRaise the build resource limit
Deployed but pods did not changeThe same commit was rebuilt with GitRef, so the tag is identicalChange the source or switch the tag policy to Unique

Even with credentials registered, a wrong value or insufficient permission fails at the push step. Do not check only that the Secret exists; check its contents too (see 3.4).