KAHIBARO Bookshelves
Discord Login Register

7. Building and Deploying Applications

Learning goals for this chapter

After this chapter you should be able to:

  • Understand how applications are typically built and deployed on OpenShift.
  • Navigate the main OpenShift objects involved in application deployment.
  • Compare build and deployment approaches (S2I vs pre-built images, etc.).
  • Recognize how OpenShift’s opinionated workflow differs from “raw” Kubernetes.

This chapter provides the foundation; the following subchapters will dive deeper into each major mechanism (S2I, container-based, DeploymentConfigs, rollouts, etc.).

The OpenShift view of “an application”

On OpenShift, “an application” is usually not a single object but a collection of resources:

  • A container image (from S2I or a registry).
  • One or more Deployment or DeploymentConfig objects that define how pods are run.
  • Services and Routes/Ingress for network access (covered elsewhere).
  • ConfigMaps, Secrets, PVCs, etc. for configuration and data (covered elsewhere).
  • Optionally, build resources (BuildConfig, ImageStream) if you build in-cluster.

Conceptually, OpenShift standardizes three phases:

  1. Build – how code becomes a container image.
  2. Deploy – how that image is run as pods.
  3. Release / expose – how users or other systems access it.

This chapter focuses on the first two: building and deploying.

Build models in OpenShift

OpenShift supports multiple ways to produce container images. The choice has a big impact on workflows, permissions, and automation.

1. In-cluster builds (OpenShift-native)

These are builds that run inside the cluster as Kubernetes pods and are managed by OpenShift.

Key native components:

  • BuildConfig – defines how to build (strategy, source, output).
  • Build – a specific build run created from a BuildConfig.
  • ImageStream – a named, versioned view of images, often used as build inputs/outputs.

Core strategies (explained in detail in later subchapters):

  • Source-to-Image (S2I) builds – take source code + builder image → application image.
  • Docker builds – build from a Dockerfile in source repo.
  • Custom builds – advanced, user-defined builder images.

When you trigger a build (manually, via webhook, or automatically):

  1. OpenShift creates a Build object.
  2. A build pod runs the chosen build strategy.
  3. The resulting image is pushed to an internal registry and tracked via an ImageStream.

Advantages:

  • No extra external CI infrastructure required.
  • Works well with internal registries and security policies.
  • Integrates tightly with deployment triggers.

Trade-offs:

  • Build workloads consume cluster resources.
  • Often better for small/medium apps or where central platform teams manage builds.

2. External CI/CD builds

In this model, building the image happens outside OpenShift:

  • External CI systems (Jenkins, GitLab CI, GitHub Actions, etc.) build images.
  • Images are pushed to an internal or external registry.
  • OpenShift is mainly responsible for deployment, not building.

Typical pattern:

  1. Developer pushes code.
  2. External CI builds and tests the image.
  3. CI pushes image to registry (e.g. Quay, Docker Hub, internal registry).
  4. CI calls oc apply / oc rollout or updates image tags to deploy on OpenShift.

Advantages:

  • Offloads build workloads from the cluster.
  • Reuses existing DevOps tooling.
  • Easier to enforce complex pipelines, tests, and quality gates.

Trade-offs:

  • More moving parts to manage and secure.
  • You must integrate image update signals with OpenShift deployments.

3. Hybrid models

Organizations frequently mix approaches:

  • Critical services: built externally, deployed carefully with strong approvals.
  • Simpler line-of-business apps: built using OpenShift-native S2I and BuildConfigs.
  • Experimental or training projects: built via web console “Add to Project” workflows.

Understanding that OpenShift supports all these patterns is central to designing a workable application delivery process.

Deployment models in OpenShift

Once you have an image, OpenShift runs it as pods using workload controllers. On OpenShift, you will commonly see:

  • Deployments (Kubernetes-native, recommended for new apps).
  • DeploymentConfigs (OpenShift-specific, legacy but still widely used).

You will explore these in depth in the dedicated subchapter. For now, it’s important to understand:

  • Both represent a desired state of running pods (replicas, template, update strategy).
  • They manage rollouts (updating from one version to another).
  • They integrate with Services and Routes to keep traffic flowing during changes.

Basic deployment workflow

Conceptually, a typical deployment goes through:

  1. Define the pod template
    • Container image (e.g. quay.io/org/app:1.0.3).
    • Environment variables, ports, resource requests/limits.
    • Configurations via ConfigMaps/Secrets/Volumes.
  2. Wrap the template in a controller
    • Use a Deployment or DeploymentConfig with:
      • replicas: how many pods.
      • strategy: how to roll out changes (rolling, recreate, etc.).
  3. Connect to the network
    • A Service provides stable DNS and load balancing across pods.
    • A Route or Ingress exposes the service externally if needed.
  4. Roll out changes
    • Update image tags, environment variables, or other fields.
    • The controller orchestrates creating new pods and scaling down old ones.

Application deployment approaches

From a developer’s point of view, there are two main ways to “get an app running”:

1. “Bring your own image” (container-based deployments)

You use a pre-built image, often produced by an external CI/CD system:

  • Minimal OpenShift-specific configuration:
    • Deployment pointing at image: your-registry/your-app:tag.
    • Optional HorizontalPodAutoscaler, ConfigMaps, Secrets, PVCs, etc.

This is close to vanilla Kubernetes and is covered in detail later in “Container-based deployments”.

2. “Bring your source code” (S2I-based workflows)

You give OpenShift access to your source code repository and a builder image; OpenShift:

  • Builds the image inside the cluster with S2I.
  • Stores it in an internal registry.
  • Triggers a deployment automatically.

OpenShift’s web console and oc new-app strongly encourage this pattern:

  • Developers can start from source repos quickly.
  • Platform teams can standardize on supported builder images.

This is the focus of the upcoming “Source-to-Image (S2I)” subchapter.

Integrating builds and deployments

A key benefit of OpenShift’s opinionated model is automated promotion from build to running application.

Typical integration mechanisms:

  • Image change triggers on Deployment/DeploymentConfig:
    • Watch an ImageStreamTag (e.g. myapp:latest).
    • When the image changes (after a new build), trigger a rollout.
  • Build triggers on BuildConfig:
    • Webhooks from Git, or image-change triggers from builder images.
    • Build starts automatically when source or base image changes.

By combining these:

  1. Code is pushed → BuildConfig starts a build.
  2. Build produces a new image in an ImageStream.
  3. Image change trigger fires on the Deployment/DeploymentConfig.
  4. A rollout to the new version starts automatically.

This creates a basic in-cluster CI-like pipeline without external tooling. The CI/CD-focused chapter and subchapters will cover more advanced pipelines and GitOps patterns.

Environment separation and promotion

Most real deployments have multiple environments:

  • dev / test / staging / prod projects or namespaces.
  • Different levels of access control and resource limits.

Common patterns for managing this in OpenShift:

  • Same image, different configuration:
    • Promote the same container image through environments.
    • Only change configuration (ConfigMaps/Secrets, replicas, limits, routes).
  • Image promotion via tags or ImageStreams:
    • Use distinct image tags (e.g. :dev, :staging, :prod) or ImageStreams.
    • Promotion is done by retagging or copying images between registries/namespaces.
  • Separate Build & Deploy responsibilities:
    • dev project builds images.
    • test / prod projects deploy only approved images from controlled registries.

This separation is essential for compliance and governance and is built into how many OpenShift clusters are organized.

Developer workflows on OpenShift

While the details differ by organization, a typical OpenShift-based developer workflow looks like:

  1. Initial onboarding
    • Get access to a project/namespace.
    • Choose a deployment model: S2I or container-based.
  2. First deployment
    • Use oc new-app or the web console to create a basic application.
    • Confirm pods, services, and routes are created and healthy.
  3. Iterative development
    • Modify code, push to Git.
    • Build and deploy automatically via:
      • OpenShift BuildConfigs, or
      • External CI/CD triggering oc commands or GitOps flows.
  4. Observability and tuning
    • Inspect logs, events, and metrics.
    • Adjust resource requests/limits and scaling.
    • Modify deployment strategy for faster or safer rollouts.
  5. Promotion to higher environments
    • Use pipelines, manual approvals, or GitOps to move changes toward production.

Later chapters (CI/CD, monitoring, security, scaling) will expand on each of these aspects; this chapter’s role is to show how the core building and deployment mechanisms underpin the whole workflow.

Design considerations for building and deploying on OpenShift

When deciding how to structure your builds and deployments, you should think about:

  • Where builds run
    • In-cluster (OpenShift BuildConfigs/S2I) vs external CI runners.
    • Security and resource consumption in the cluster.
  • How images are managed
    • Use of internal registry vs external registries.
    • Use of ImageStreams for tracking and triggers.
  • How changes are rolled out
    • Choice of Deployment vs DeploymentConfig.
    • Rollout strategies (rolling vs recreate) and their tuning.
    • Use of rolling updates and rollbacks (covered later).
  • How configuration is separated from code
    • Use of ConfigMaps, Secrets, and environment variables.
    • Keeping images generic and environment-agnostic.
  • How environments and teams are isolated
    • Projects/namespaces per team or application.
    • Access control and quotas influencing deployment patterns.

Each of the following subchapters will focus on one part of this overall picture—S2I, container-based deployments, DeploymentConfigs/Deployments, and rollout strategies—to give you practical tools for implementing robust application delivery on OpenShift.

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!

Where to Move

Move chapter:

  • ☰ 1. Course Overview
    • ☰ 1.1. What is OpenShift
      • ☰ 1.2. Why OpenShift is used in modern IT and cloud environments
        • ☰ 1.3. OpenShift vs Kubernetes
          • ☰ 1.4. Typical OpenShift use cases
            • ☰ 1.5. Structure and goals of the course
            • ☰ 2. Containers and Cloud-Native Fundamentals
              • ☰ 2.1. What is a container
                • ☰ 2.2. Containers vs virtual machines
                  • ☰ 2.3. Introduction to Docker and container images
                    • ☰ 2.4. Container registries
                      • ☰ 2.5. Basics of cloud-native applications
                      • ☰ 3. Kubernetes Fundamentals
                        • ☰ 3.1. What is Kubernetes
                          • ☰ 3.2. Kubernetes architecture
                            • ☰ 3.3. Control plane components
                              • ☰ 3.4. Worker node components
                                • ☰ 3.5. Kubernetes objects and resources
                                  • ☰ 3.6. Declarative configuration model
                                  • ☰ 4. OpenShift Architecture
                                    • ☰ 4.1. Overview of OpenShift architecture
                                      • ☰ 4.2. Control plane in OpenShift
                                        • ☰ 4.3. Nodes and machine roles
                                          • ☰ 4.4. OpenShift Operators
                                            • ☰ 4.5. OpenShift networking model
                                              • ☰ 4.6. OpenShift storage model
                                              • ☰ 5. OpenShift Installation and Deployment Models
                                                • ☰ 5.1. OpenShift deployment options
                                                  • ☰ 5.2. Installer-Provisioned Infrastructure
                                                    • ☰ 5.3. User-Provisioned Infrastructure
                                                      • ☰ 5.4. Managed OpenShift services
                                                        • ☰ 5.5. Single-node OpenShift
                                                          • ☰ 5.6. Cluster lifecycle management
                                                          • ☰ 6. Accessing and Using OpenShift
                                                            • ☰ 6.1. OpenShift web console
                                                              • ☰ 6.2. OpenShift CLI (oc)
                                                                • ☰ 6.3. Authentication and authorization
                                                                  • ☰ 6.4. Projects and namespaces
                                                                    • ☰ 6.5. Resource quotas and limits
                                                                    • ☰ 7. Building and Deploying Applications
                                                                      • ☰ 7.1. Application deployment concepts
                                                                        • ☰ 7.2. Source-to-Image (S2I)
                                                                          • ☰ 7.3. Container-based deployments
                                                                            • ☰ 7.4. DeploymentConfigs and Deployments
                                                                              • ☰ 7.5. Rolling updates and rollbacks
                                                                              • ☰ 8. Networking in OpenShift
                                                                                • ☰ 8.1. Services and service discovery
                                                                                  • ☰ 8.2. Routes and ingress
                                                                                    • ☰ 8.3. Network policies
                                                                                      • ☰ 8.4. Load balancing
                                                                                        • ☰ 8.5. External access to applications
                                                                                        • ☰ 9. Storage in OpenShift
                                                                                          • ☰ 9.1. Persistent storage concepts
                                                                                            • ☰ 9.2. Persistent Volumes
                                                                                              • ☰ 9.3. Persistent Volume Claims
                                                                                                • ☰ 9.4. StorageClasses
                                                                                                  • ☰ 9.5. Dynamic provisioning
                                                                                                    • ☰ 9.6. Stateful applications
                                                                                                    • ☰ 10. Configuration and Secrets Management
                                                                                                      • ☰ 10.1. ConfigMaps
                                                                                                        • ☰ 10.2. Secrets
                                                                                                          • ☰ 10.3. Environment variables
                                                                                                            • ☰ 10.4. Managing sensitive data
                                                                                                              • ☰ 10.5. Best practices for configuration
                                                                                                              • ☰ 11. Scaling and High Availability
                                                                                                                • ☰ 11.1. Horizontal pod autoscaling
                                                                                                                  • ☰ 11.2. Vertical scaling
                                                                                                                    • ☰ 11.3. Self-healing and pod restarts
                                                                                                                      • ☰ 11.4. High availability concepts
                                                                                                                        • ☰ 11.5. Multi-zone and multi-region clusters
                                                                                                                        • ☰ 12. Monitoring, Logging, and Observability
                                                                                                                          • ☰ 12.1. Built-in monitoring stack
                                                                                                                            • ☰ 12.2. Metrics and alerts
                                                                                                                              • ☰ 12.3. Logging architecture
                                                                                                                                • ☰ 12.4. Distributed tracing
                                                                                                                                  • ☰ 12.5. Troubleshooting applications
                                                                                                                                  • ☰ 13. Security in OpenShift
                                                                                                                                    • ☰ 13.1. Security model overview
                                                                                                                                      • ☰ 13.2. Role-Based Access Control
                                                                                                                                        • ☰ 13.3. Security Context Constraints
                                                                                                                                          • ☰ 13.4. Image security and scanning
                                                                                                                                            • ☰ 13.5. Network security
                                                                                                                                              • ☰ 13.6. Compliance and auditing
                                                                                                                                              • ☰ 14. CI/CD and DevOps with OpenShift
                                                                                                                                                • ☰ 14.1. DevOps concepts
                                                                                                                                                  • ☰ 14.2. CI/CD pipelines overview
                                                                                                                                                    • ☰ 14.3. OpenShift Pipelines (Tekton)
                                                                                                                                                      • ☰ 14.4. GitOps with Argo CD
                                                                                                                                                        • ☰ 14.5. Integrating OpenShift with external CI tools
                                                                                                                                                        • ☰ 15. Operators and Platform Services
                                                                                                                                                          • ☰ 15.1. What are Operators
                                                                                                                                                            • ☰ 15.2. Operator Lifecycle Manager
                                                                                                                                                              • ☰ 15.3. Installing and managing Operators
                                                                                                                                                                • ☰ 15.4. Common platform Operators
                                                                                                                                                                  • ☰ 15.5. Custom Operators
                                                                                                                                                                  • ☰ 16. Upgrades, Maintenance, and Operations
                                                                                                                                                                    • ☰ 16.1. OpenShift upgrade process
                                                                                                                                                                      • ☰ 16.2. Backup and restore
                                                                                                                                                                        • ☰ 16.3. Node maintenance
                                                                                                                                                                          • ☰ 16.4. Cluster troubleshooting
                                                                                                                                                                            • ☰ 16.5. Capacity planning
                                                                                                                                                                            • ☰ 17. OpenShift on HPC and Specialized Workloads
                                                                                                                                                                              • ☰ 17.1. Running batch workloads on OpenShift
                                                                                                                                                                                • ☰ 17.2. OpenShift and GPUs
                                                                                                                                                                                  • ☰ 17.3. MPI and parallel workloads in containers
                                                                                                                                                                                    • ☰ 17.4. Hybrid HPC and cloud workflows
                                                                                                                                                                                    • ☰ 18. OpenShift in Practice
                                                                                                                                                                                      • ☰ 18.1. Typical OpenShift workflows
                                                                                                                                                                                        • ☰ 18.2. Development to production lifecycle
                                                                                                                                                                                          • ☰ 18.3. Case studies from industry
                                                                                                                                                                                            • ☰ 18.4. Common pitfalls and best practices
                                                                                                                                                                                            • ☰ 19. Future Directions and Ecosystem
                                                                                                                                                                                              • ☰ 19.1. Kubernetes ecosystem overview
                                                                                                                                                                                                • ☰ 19.2. OpenShift roadmap
                                                                                                                                                                                                  • ☰ 19.3. Serverless and event-driven workloads
                                                                                                                                                                                                    • ☰ 19.4. AI and data platforms on OpenShift
                                                                                                                                                                                                    • ☰ 20. Final Project and Hands-On Exercises
                                                                                                                                                                                                      • ☰ 20.1. Deploying a containerized application
                                                                                                                                                                                                        • ☰ 20.2. Implementing CI/CD with OpenShift
                                                                                                                                                                                                          • ☰ 20.3. Securing and scaling an application
                                                                                                                                                                                                            • ☰ 20.4. Monitoring and troubleshooting report