Architecture Of Konflux

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.

Build Service Architecture

# 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.

Controller will also create component specific service account build-pipeline-$COMPONENT_NAME used for build pipelines. See Service Account Management below.

PaC provision:

  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. 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 occurs.
  3. Removes build.appstudio.openshift.io/request annotation.

# Build Pipeline Configuration

Available and default pipelines are defined in a ConfigMap named build-pipeline-config in the controller’s namespace.

Build pipeline is selected based on build.appstudio.openshift.io/pipeline annotation. When annotation is missing, Build Service adds the annotation with the default pipeline from the ConfigMap.

Annotation format:

{"name":"docker-build","bundle":"latest"}

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

Example ConfigMap structure:

apiVersion: v1
kind: ConfigMap
metadata:
  name: build-pipeline-config
  namespace: build-service
data:
  default_build_bundle: "quay.io/konflux-ci/tekton-catalog/pipeline-docker-build:latest"
  pipelines: |
    - name: docker-build
      bundle: quay.io/konflux-ci/tekton-catalog/pipeline-docker-build:latest
    - name: fbc-builder
      bundle: quay.io/konflux-ci/tekton-catalog/pipeline-fbc-builder:latest

Reference implementations:

# PipelineRun parameters

Build Service sets the following parameters in generated PipelineRuns:

Parameter Source Notes
git-url {{source_url}} PaC template variable, evaluated to git repository URL
revision {{revision}} PaC template variable, evaluated to git commit SHA
output-image Component .spec.containerImage Push pipeline: appends :{{revision}}
PR pipeline: appends :on-pr-{{revision}}
image-expires-after ENV IMAGE_TAG_ON_PR_EXPIRATION PR builds only, defaults to value in code
dockerfile Component .spec.source.git.dockerfileUrl Defaults to Dockerfile
path-context Component .spec.source.git.context Optional, subdirectory for build context

Additional pipeline-specific parameters may be defined in the build pipelines ConfigMap with additional-params, which will be added with default values from the pipeline itself.

# Service Account Management

Build Service creates a dedicated service account for each Component: build-pipeline-$COMPONENT_NAME.

Benefits:

Historical Context: Previously, a shared appstudio-pipeline service account was used across all components in a namespace. See ADR-0025 for details on the migration to per-component service accounts.

The service account is automatically linked with:

# 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).

Process:

  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. If ReleasePlanAdmission CRs exist for the component, it will also discover distribution repositories and include references to those registries in the updates.
  5. Renovate will create merge request in user’s repository if it finds matches.
  6. Removes build.appstudio.openshift.io/build-nudge-finalizer finalizer from PipelineRun.

Configuration:

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

Users can modify the file pattern list via:

Related ADRs:

# Integration with Other Services

# Hybrid Application Service

# Integration Service

# Release Service

# Image Controller

# Security Considerations

# Credential Management

# Webhook Security

# Service Account Isolation

Each Component uses a dedicated service account with minimal permissions:

See ADR-0011: Roles and Permissions for RBAC design.

# Known Limitations

# Controllers Cannot Be Individually Disabled

All three controllers (Component Build, PaC PipelineRun Pruner, Component Dependency Update) are unconditionally enabled when Build Service starts. This means:

# Webhook Management Constraints