๐Ÿ“ Automating Builds in OpenShift: BuildConfig & ImageStreams Explained

Openshift RSH Network November 29, 2025 2 mins read

Discover how OpenShift uses BuildConfig and ImageStreams to automate container image creation and updates directly from your source code.

1. Introduction

OpenShift automates container builds using two key resources: BuildConfig and ImageStreams.
Together, they provide a powerful CI/CD workflow that automatically rebuilds and deploys images whenever source code or base images change. This enables development teams to achieve seamless, automated build pipelines without external tools.


2. ๐Ÿ—๏ธ What Is BuildConfig?

A BuildConfig (BC) is a custom OpenShift resource that defines how an image should be built from source.

๐Ÿ”ง Key Build Strategies

  • Source-to-Image (S2I) — Converts source code into an image using language-specific builders

  • Docker Build — Builds using a Dockerfile

  • Custom Build — Allows defining your own builder logic

๐Ÿ“„ Sample BuildConfig YAML

 
apiVersion: build.openshift.io/v1 kind: BuildConfig metadata: name: nodejs-app spec: source: git: uri: https://github.com/rshnetwork/nodejs-app.git strategy: type: Source output: to: kind: ImageStreamTag name: nodejs-app:latest

This BuildConfig automatically builds a new NodeJS app image whenever the Git repository changes.


3. ๐Ÿ–ผ๏ธ What Is an ImageStream?

An ImageStream (IS) tracks changes to images and can trigger builds or deployments accordingly.

โœจ Benefits of ImageStreams

  • Decouples image tags from external registries

  • Enables automatic rebuilds when base images update

  • Integrates tightly with BuildConfig and DeploymentConfig

๐Ÿ“Œ Trigger Example

 
triggers: - type: ImageChange

This tells OpenShift to automatically rebuild/redeploy when the associated image changes.


4. ๐Ÿ”„ Workflow Overview

Here’s how the BuildConfig + ImageStream automation works:

  1. Developer pushes code to Git.

  2. ImageStream detects the updated image tag or Git change.

  3. BuildConfig triggers a new build.

  4. A new image is created and stored in the internal registry.

  5. DeploymentConfig or Deployment updates automatically.

This forms the core of OpenShift’s native CI/CD pipeline.


5. ๐Ÿงช Troubleshooting Tips

Check build logs

 
oc logs bc/nodejs-app

Inspect ImageStream status

 
oc describe is nodejs-app

Validate triggers in BuildConfig

 
oc get bc nodejs-app -o yaml

6. โœ… Best Practices

โœ”๏ธ Use S2I for language-based applications
โœ”๏ธ Tag images cleanly (:dev, :stage, :prod)
โœ”๏ธ Secure Git credentials using Secrets
โœ”๏ธ Enable ImageChange triggers for auto-build workflows
โœ”๏ธ Use Webhooks for instant build triggers from GitHub/GitLab

Advertisement

R
RSH Network

39 posts published

Sign in to subscribe to blog updates