MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

OpenShift BuildConfig Tutorial

โœ… What is OpenShift BuildConfig?

BuildConfig in OpenShift is a Kubernetes-native custom resource provided by OpenShift that defines how to build a container image from source code. It automates the end-to-end image build process โ€” from fetching source code to producing and storing container images โ€” using build strategies like Source-to-Image (S2I), Docker, or custom workflows.


๐Ÿ“˜ BuildConfig Definition

A BuildConfig is a declarative configuration object in OpenShift that defines the strategy, source, triggers, and output for building container images automatically or on-demand.

Itโ€™s like a recipe for converting application source code into a deployable container image.


โญ Key Features of BuildConfig

FeatureDescription
๐ŸŽฏ Multiple Build StrategiesSupports S2I, Dockerfile, and Custom strategies.
๐Ÿ”— Git IntegrationPulls source code directly from public/private Git repositories.
๐Ÿ” Automatic TriggersRebuilds can be triggered by Git changes, image changes, or config changes.
๐Ÿ›  Custom Build EnvironmentSupports environment variables, secrets, and configmaps during builds.
๐Ÿท๏ธ ImageStream IntegrationBuilt images can be pushed to internal ImageStreams or external registries.
๐Ÿ‘ฅ WebhooksAllows GitHub/GitLab to trigger builds via webhooks.
๐Ÿ” Build Logs & HistoryEasily view build logs, status, and retry failed builds.
๐Ÿ” Secure Build ContextsSupports source credentials, secrets, and isolated build pods.

๐Ÿ”ง Example Use Cases

ScenarioHow BuildConfig Helps
CI/CD automationAuto-rebuild on Git push or base image update
DevOps in hybrid cloudWorks with internal and external image registries
Compliance & traceabilityFull build history and image tracking
S2I app deployment (Node.js, Python, etc.)Uses language-specific builder images

๐Ÿ“ฆ BuildConfig vs Dockerfile vs Pipelines

Tool/ConceptRole
BuildConfigDefines how to build an image from source
DockerfileManual build instructions (used in Docker strategy)
PipelinesOrchestrates multiple stages/jobs (Tekton-based)

๐Ÿš€ BuildConfig Lifecycle

  1. Developer pushes code to Git
  2. OpenShift triggers a build (via webhook or manually)
  3. Code is fetched and built using specified strategy
  4. Final image is stored (ImageStream or registry)
  5. App is deployed or updated automatically

โœ… Works on OpenShift 4.13+ (including Azure Red Hat OpenShift)


๐ŸŽฏ Goal

Build a Node.js application using:

  • โœ… Git source
  • โœ… External Red Hat base image (ubi8/nodejs-16)
  • โœ… OpenShift S2I strategy (using DockerImage)
  • โœ… No need for preloaded ImageStreams

๐Ÿงฑ Prerequisites

RequirementDetails
OpenShift clusterAccess to 4.13+ (Azure, local, etc.)
Project createdUse oc new-project or create via Web UI
GitHub repo with app codee.g., sclorg/nodejs-ex
OpenShift CLI (optional)oc logged in

๐Ÿงพ Option 1: YAML Method (CLI or Web Console YAML Editor)

โœ… Step-by-Step (Using YAML)

  1. Create/Open a project oc new-project nodejs-s2i-demo
  2. Apply this working BuildConfig YAML:
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: nodejs-sample-build
  labels:
    app: nodejs-sample
spec:
  source:
    type: Git
    git:
      uri: https://github.com/sclorg/nodejs-ex.git
      ref: main
    contextDir: .
  strategy:
    type: Source
    sourceStrategy:
      from:
        kind: DockerImage
        name: registry.access.redhat.com/ubi8/nodejs-16
      forcePull: true
  output:
    to:
      kind: ImageStreamTag
      name: nodejs-sample:latest
  triggers:
    - type: ConfigChange
    - type: ImageChange
  runPolicy: Serial
Code language: JavaScript (javascript)
  1. Start the build manually: oc start-build nodejs-sample-build --follow
  2. Deploy the built image: oc new-app nodejs-sample oc expose svc/nodejs-sample
  3. Access the app: oc get route

๐Ÿ–ฑ๏ธ Option 2: Using the OpenShift Developer Console UI

Based on your screenshots โ€” modern and guided flow

โœ… Step-by-Step (Using Developer Web Console)

  1. Go to Developer โ†’ +Add โ†’ From Git
  2. Fill Git Repository info:
    • Git Repo URL: https://github.com/sclorg/nodejs-ex.git
    • Git Reference: main (or leave blank)
    • Context Dir: .
  3. Builder Image Selection (Build from):
    • Select โ€œDocker Imageโ€ from the build option dropdown
    • Input Docker Image: registry.access.redhat.com/ubi8/nodejs-16
  4. Deployment Settings:
    • App Name: nodejs-sample
    • Resources: Deployment (leave default)
    • Create Route: โœ… (enabled)
  5. Click “Create”

OpenShift will:

  • Create BuildConfig, ImageStream, Deployment, and Route
  • Trigger an initial build
  • Watch progress from Builds or Topology

๐Ÿงช How to Monitor

  • Build logs:
    Developer โ†’ Builds โ†’ nodejs-sample-build โ†’ View Logs
  • Application route:
    Developer โ†’ Topology โ†’ Click route link
  • BuildConfig YAML:
    Admin โ†’ Builds โ†’ nodejs-sample-build โ†’ YAML

๐Ÿ” Updating Code

Just push code to GitHub and trigger a build manually:

oc start-build nodejs-sample-build

Or setup GitHub webhook using:

oc describe bc nodejs-sample-build

โœ… Summary

StepUI PathYAML Equivalent
Git sourceFrom Gitsource.git.uri
Docker imageSelect โ€œDocker Imageโ€strategy.sourceStrategy.from.kind: DockerImage
DeploymentAuto-created via +AddUse oc new-app after build manually
RouteEnabled in UIoc expose svc/nodejs-sample

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Azure Devops Pipeline YAML Example

This page shows a minimal Azure Pipelines YAML file that builds a Docker image with the Docker@2 task on a Microsoft-hosted Ubuntu agent each time code is…

Read More

Docker Tutorials: Docker Image – Example and Sample Programs of Dockerfile

This page collects sample Dockerfiles that build an Ubuntu-based Apache image and show how CMD, ENTRYPOINT, EXPOSE, ARG, ENV, COPY and USER behave. Below the examples you…

Read More

Kubernetes: Pull an Image from a Private Registry using Yaml and Helm File

Kubernetes pulls images from a private registry using a kubernetes.io/dockerconfigjson Secret. A Pod references that Secret through imagePullSecrets, either directly or through its ServiceAccount. This page shows…

Read More

Docker Training Agenda: A Hands-On Learning Path from Containers to Registries and Networking

This revised Docker training agenda turns the original outline into a practical, modern learning path for beginners and early-career DevOps engineers. It maps each module to hands-on outcomes, core commands, and common implementation decisions.

Read More

Install Sonatype Nexus with Docker: RM2/RM3 Commands, Validation Steps, and Important Caveats

A structured, production-minded rewrite of the original 2016 Docker setup for Sonatype Nexus Repository Manager 2 and 3. Includes command examples, a workflow diagram, and clear warnings about outdated tags/endpoints.

Read More

Virtualization in DevOps: Using Vagrant, Docker, and Cloud Platforms Together

This guide explains how VM-based workflows, containers, and cloud platforms complement each other in DevOps. It includes a practical workflow, trade-off table, and command examples for day-to-day use.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x