Build Service

Overview

The Build Service is composed of controllers that create and configure build pipelines. The main input for the Build Service is a Component CR managed by the Konflux UI or created manually via kubectl.

Dependencies

The Build Service is dependent on the following services:

Controllers

The Build Service contains these controllers:

Component Build Controller

Component Build Controller is managed by Component CR changes (creation or update). It’s using Component CR annotations and configuration of the PipelineRuns.

Modes

The prerequisite is to have installed GitHub App which is used by the Build Service in the user’s repository, or have gitlab/github secret created for usage via webhook (creating GitLab secrets).

Component Build Controller is working in multiple ways based on a request annotation build.appstudio.openshift.io/request:

All those requests first wait for .spec.containerImage to be set, either manually or by image-controller via ImageRepository CR.

PaC provision:

  1. Sets up webhook in the respository if GitHub App isn’t used.
  2. Creates or reuses Repository CR (Component CR is set as the owner).
  3. Creates merge request in the user code repository with PipelineRun definitions.
  4. Sets build.appstudio.openshift.io/status annotation with either error, or state enabled and merge request link.
  5. Sets finalizer pac.component.appstudio.openshift.io/finalizer.
  6. Removes build.appstudio.openshift.io/request annotation.

PaC provision without MR creation:

  1. Sets up webhook in the repository if GitHub App isn’t used.
  2. Creates or reuses Repository CR (Component CR is set as the owner).
  3. Doesn’t create merge request in the user code repository with PipelineRun definitions, that is up to user.
  4. Sets build.appstudio.openshift.io/status annotation with either error, or state enabled.
  5. Sets finalizer pac.component.appstudio.openshift.io/finalizer.
  6. Removes build.appstudio.openshift.io/request annotation.

PaC unprovision:

  1. Removes finalizer pac.component.appstudio.openshift.io/finalizer.
  2. Removes webhook from repository if GitHub App isn’t used and the repository isn’t used in another component.
  3. Creates merge request in the user code repository removing PipelineRun definitions.
  4. Sets build.appstudio.openshift.io/status annotation with either error, or state disabled and merge request link.
  5. Removes build.appstudio.openshift.io/request annotation.

Trigger PaC build:

  1. Triggers push pipeline via PaC incoming webhook, requires pipeline run name to be the same as it was named during provisioning $COMPONENT_NAME-on-push.
  2. Sets build.appstudio.openshift.io/status annotation when error occures.
  3. Removes build.appstudio.openshift.io/request annotation.

PipelineRun selection

Available and default pipelines are in the config map present on the cluster in controller’s namespace build pipelines config.

Build pipeline is selected based on build.appstudio.openshift.io/pipeline annotation, when annotation is missing, annotation with default pipeline (based on config map) will be added.

Annotation value is json in string eg. '{"name":"docker-build","bundle":"latest"}. Name is the name of the pipeline, and the bundle is either latest which will use the tag from config map or specific tag for the bundle (used mostly for testing).

When specified pipeline doesn’t exist in config map, it will result with error.

PipelineRun parameters

There are a few parameters that are set in PipelineRun created by the Build Service:

Additionally in build pipelines config pipelines may have specified additional-params which will be added with default values from pipeline itself.

PaC PipelineRun Pruner Controller

The purpose of the PaC PipelineRun Pruner Controller is to remove the PipelineRun CRs created for Component CR which is being deleted.

It will remove all PipelineRuns based on appstudio.openshift.io/component label in PipelineRun.

Component dependency update controller (nudging)

Monitors push PipelineRuns and based on defined relationships runs renovate, which updates SHA for the image produced by PipelineRun in user’s repository.

Relationships can be set in a Component CR via spec.build-nudges-ref (list of components to be nudged)

  1. When PipelineRun is for a component which has set spec.build-nudges-ref, it will add finalizer to it build.appstudio.openshift.io/build-nudge-finalizer.
  2. It will wait for PipelineRun to successfully finish.
  3. When PipelineRun successfully finishes, it will run renovate on user’s repositories (for components specified in spec.build-nudges-ref), updating files with SHA of the image which was built by PipelineRun.
  4. Renovate will create merge request in user’s repository if it finds matches.
  5. Removes build.appstudio.openshift.io/build-nudge-finalizer finalizer from PipelineRun.

Default files which will be nudged are: .*Dockerfile.*, .*.yaml, .*Containerfile.*.

Users can modify list via: