OpenShift

What is OpenShift?

OpenShift is a Kubernetes-based enterprise container platform developed by Red Hat.
It provides everything you need to build, deploy, manage, and scale applications using containers.

Think of OpenShift as:

  • Kubernetes + more automation + built-in security + developer tools + enterprise support.


Key Components of OpenShift

1. Kubernetes (Core Orchestrator)

OpenShift is built on top of Kubernetes and includes:

  • Pod & container orchestration

  • Service discovery

  • Auto-scaling

  • Load balancing

2. OpenShift API Server

  • Central control point

  • Manages all cluster operations

3. OpenShift Container Registry (OCR)

  • Built-in Docker-compatible registry

  • Stores images internally in a secure manner

4. OpenShift Router

  • Based on HAProxy

  • Handles external traffic

  • Supports routes, TLS, sticky sessions, etc.

5. Operators

  • Automate lifecycle of apps & infrastructure (install → upgrade → manage)

  • OpenShift uses OperatorHub to provide many certified operators

6. Developer Tools

  • Source-to-Image (S2I): build apps from source code

  • Dev Spaces (formerly CodeReady Workspaces)

  • Pipelines (Tekton-based CI/CD)

  • GitOps (ArgoCD)


Types of OpenShift Platforms

1. OpenShift Container Platform (OCP)

  • Self-managed version

  • Install on your own infrastructure (on-prem, private cloud, bare-metal)

2. OpenShift Online

  • Fully managed SaaS offering by Red Hat

3. OpenShift Dedicated

  • Customer-specific cluster

  • Managed by Red Hat on AWS or GCP

4. ROSA (Red Hat OpenShift on AWS)

  • Joint Red Hat–AWS managed service

5. ARO (Azure Red Hat OpenShift)

  • Joint Red Hat–Microsoft managed platform


Architecture Overview

OpenShift has 3 major layers:

1. Master/Control Plane

  • API Server

  • etcd

  • Scheduler

  • Controller Manager

  • Machine API

2. Worker Nodes

  • Run containers/pods

  • Include:

    • CRI-O or Docker runtime

    • Kubelet

    • Node services

3. Services Layer

  • Monitoring (Prometheus)

  • Logging / EFK stack

  • Image registry

  • Networking (OpenShift SDN / OVN-Kubernetes)


Key Features of OpenShift

Enterprise Security

  • Role-Based Access Control (RBAC)

  • Image scanning (Clair)

  • Network policies

  • Security Context Constraints (SCC)

Built-in CI/CD

  • Tekton pipelines

  • ArgoCD for GitOps

Developer-Friendly

  • Web console + dashboard

  • S2I build system

  • UI-based deployment

  • Integrated logging & monitoring

Autoscaling

  • Horizontal Pod Autoscaler

  • Cluster autoscaler

  • Machine autoscaler

Multi-Cloud + Hybrid Support

  • Deploy anywhere

  • Consistent experience across environments


How Deployment Works in OpenShift

  1. Developer pushes code to Git repo

  2. OpenShift pipeline triggers build

  3. Build creates Docker image / S2I image

  4. Image is stored in internal registry

  5. DeploymentConfig or Deployment creates pods

  6. Router exposes app through a public route


Command Line Tools

1. oc CLI (OpenShift Client)

Used to interact with OpenShift, similar to kubectl but with extra features:

oc login oc new-project oc new-app oc get pods oc logs oc expose service/myapp

2. kubectl

Also works because OpenShift is Kubernetes under the hood.


OpenShift vs Kubernetes

FeatureKubernetesOpenShift
InstallationComplexAutomated installer
SecurityBasicStrict, enterprise-grade
UI DashboardBasicAdvanced web console
Built-in CI/CDNoYes (Tekton + ArgoCD)
Image registryExternalBuilt-in
Multi-tenancyLimitedStrong security & isolation
Developer toolsMinimalStrong developer experience


Security Enhancements in OpenShift

  • SCCs (Security Context Constraints)

  • Enforces non-root containers

  • Audit logs

  • TLS everywhere

  • Vulnerability scanning


Use Cases of OpenShift

  • Microservices architecture

  • Modernizing legacy applications

  • Hybrid cloud deployments

  • Banking & FinTech applications

  • Telecom workloads

  • Enterprise CI/CD pipelines


Advantages

  • Enterprise-ready

  • Highly secure

  • Great for large teams

  • Rich developer ecosystem


Disadvantages

  • Cost is high

  • Complex for small projects

  • Steeper learning curve than basic Kubernetes



What Is OpenShift Local?

OpenShift Local is a single-node OpenShift cluster (1 master + 1 worker inside one VM).
It is used for:

  • Local learning

  • Testing

  • Small development

  • Proof-of-concept






Setup OpenShift


Enable Hyper-V on Windows 10/11 Home Edition

Option 1: Using PowerShell (Admin Mode)
Run this in PowerShell (as Administrator):

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Restart your PC.

Option 2: Enable using reference script

Reference: https://mylemans.online/posts/EnableHyperv-Windows11-Home/

Cross-check: Go to → Control Panel → Programs → Turn Windows features on or off → Ensure Hyper-V is checked.


Step 1 : Create Red Hat Developer Account

Go to: https://developers.redhat.com/register
Sign up (free) or log in with an existing Red Hat account.

You’ll need this account to download OpenShift Local and your Pull Secret.


Step 2 : Download and Install OpenShift Local (CRC)

Visit: https://developers.redhat.com/products/openshift-local/overview

Download: crc-windows-amd64.msi and install it.

Verify installation:

crc version

You should see version output.

Download Pull Secret

Go to: https://cloud.redhat.com/openshift/install/pull-secret
Save it somewhere: D:\Software\crc\pull-secret.txt


Step 3 : Setup the OpenShift Cluster

Run in CMD:

crc setup

This step:

  • Prepares virtualization & networking

  • Validates system

  • Downloads required drivers

  • Sets up image cache


Step 4 : Start the OpenShift Cluster

Run:

crc start --pull-secret-file D:\Software\crc\pull-secret.txt

You’ll see output like:

👉 Save these credentials safely.

This step will:

  • Start a VM in Hyper-V

  • Create the OpenShift cluster

  • Configure kubeadmin login

  • Set up networking

Time required: 10–20 minutes.


Step 5 : Login to OpenShift Cluster

CLI Login

Run:

crc oc-env

👉 Copy the output and run it (It will sets up the oc CLI path).

Login:

oc login -u kubeadmin -p <password>

(Password was shown during crc start.)


Web Console Login

Open browser →
https://console-openshift-console.apps-crc.testing/

Login:

  • Username: kubeadmin

  • Password: shown during crc start

You now have a running local OpenShift cluster.



OpenShift Local Is Now Ready!

You can:

  • Create projects

  • Deploy apps

  • Use S2I

  • Test routes

  • Try pipelines

  • Explore Operators


How to fully reset our CRC/OpenShift Local cluster

1. Stop the CRC VM: crc stop

2. Delete the CRC VM Completely: crc delete 
👉This clears the entire OpenShift cluster

3. Delete the CRC Cache + Configuration (Optional but recommended): Delete following folders manually,

  • C:\Users\<your-username>\.crc\
  • C:\Users\<your-username>\.kube\
4. Start CRC fresh: crc start --pull-secret-file D:\Software\crc\pull-secret.txt 
👉This will create a brand-new OpenShift cluster.

5. Login Again (fresh credentials):
Get credentials: crc console --credentials
Than login: oc login -u kubeadmin -p <password>

6. Verify API Server: oc whoami
You should now see something kubeadmin






Deploy a Spring Boot Application 

(Podman Containerized Application)

on OpenShift


Step 1 : Prepare Your App & Build Podman Image

  1. Build Spring Boot JAR:

        mvn clean install
  1. Update your application.properties or application.yml:

spring.data.mongodb.uri=mongodb://10.107.6.110:27017/truck_lease_service_db

(Use your system IP from ipconfig.)

  1. Build Podman image inside project folder (where your Containerfile is):

        podman build -t springboot-mongodb-example .
  1. Verify image:

        podman images


Step 2 : Login Podman to OpenShift Internal Registry

Make sure you set CRC environment variable PATH value: C:\Users\siraj\.crc\bin\oc

On OpenShell: Get OpenShift token 

$TOKEN = oc whoami -t

Login Podman:

podman login --tls-verify=false -u kubeadmin -p $TOKEN default-route-openshift-image-registry.apps-crc.testing


Step 3 : Tag and Push Your Image to OpenShift

Create project:

oc new-project springboot-demo

Tag your image:

podman tag springboot-mongodb-example:latest default-route-openshift-image-registry.apps-crc.testing:443/springboot-demo/springboot-mongodb-example:latest

👉 Note: Due to firewall restrictions on my local system, I was unable to push the image to the local OpenShift cluster’s image registry using the following step. As an alternative, the Podman image can also be pushed to Docker Hub and then deployed and run in the local OpenShift cluster.

Push the image:

podman push --tls-verify=false default-route-openshift-image-registry.apps-crc.testing:443/springboot-demo/springboot-mongodb-example:latest

Step 4 : Deploy Application in OpenShift

Deploy:

oc new-app springboot-mongodb-example --image-stream=springboot-mongodb-example:latest
oc expose svc/springboot-mongodb-example

Check the route:

oc get routes

Output example:

springboot-mongodb-example springboot-mongodb-example-springboot-demo.apps-crc.testing

Open:

http://springboot-mongodb-example-springboot-demo.apps-crc.testing/api/trucks

Your Spring Boot app is now deployed and accessible!


Step 5 : Verify Logs & Connectivity

Logs:

oc logs -f deployment/springboot-mongodb-example

Verify MongoDB connectivity:

oc rsh deployment/springboot-mongodb-example
nc -zv 10.107.6.110 27017

If you see Connection succeeded! → MongoDB is reachable.


Step 6 : Access Application Locally

Browser or CLI:

curl http://springboot-mongodb-example-springboot-demo.apps-crc.testing/api/trucks

You should receive your API output.


Summary

StepActionCommand/URL
1Register Red Hat Accounthttps://developers.redhat.com/register
2Download and install CRChttps://developers.redhat.com/products/openshift-local/overview
5Pull Secrethttps://cloud.redhat.com/openshift/install/pull-secret
6Setup CRCcrc setup
7Start CRCcrc start --pull-secret-file D:\Software\crc\pull-secret.txt
8Login to Consolehttps://console-openshift-console.apps-crc.testing
9Login CLIoc login -u kubeadmin -p <password>
10Build Image (Podman)podman build -t springboot-mongodb-example .
11Push to OpenShiftpodman push default-route-openshift-image-registry.apps-crc.testing/springboot-demo/springboot-mongodb-example
12Deployoc new-app & oc expose svc/...






Deploy a Spring Boot Application

(without containerized)

on Openshift using S2I

  ðŸ‘‰ No containerization needed — no Podman or Docker required

This approach allows OpenShift to automatically build your app from your GitHub repository using Source-to-Image (S2I).

Step 1: Build Your Spring Boot Project

mvn clean package

Push your project code to GitHub or GitLab.

👉 you can skip this Step-1. It is NOT required for OpenShift S2I deployment. This is only for local testing.

Step 2: Login to OpenShift

Login using the OpenShift CLI:

oc login -u kubeadmin -p <password>

Note: You can get credentials with command crc console --credentials

Create a new OpenShift project:

oc new-project springboot-helloworld-project

Step 3: Deploy the Application Using S2I

Deploy your application using the Red Hat UBI 8 OpenJDK 21 S2I builder image:

oc new-app --strategy=source registry.access.redhat.com/ubi8/openjdk-21~https://github.com/SirajChaudhary/springboot-helloworld-service.git --name=springboot-helloworld-app

OpenShift S2I will automatically:
  • Clone your Git repository

  • Build the Spring Boot JAR using Maven (inside OpenShift)

  • Create an image via S2I

  • Deploy the application pod

After completing this step, wait for 5–10 minutes to allow the build to finish within the OpenShift cluster.

Step 4: Monitor Build and Deployment

Track the build logs (Note: Track the build with following command and make sure build complete before hitting next commands):

oc logs -f buildconfig/springboot-helloworld-app

Check pod status:
oc get pods

Step 5: Expose the Service (Create a Route)

Expose your application so it can be accessed externally:

oc expose service/springboot-helloworld-app

Retrieve the route URL:

oc get route

Open the route URL in a browser. your Spring Boot Hello World Application will now be running on OpenShift!


Step 6: Access OpenShift deployed microservice API

curl http://springboot-helloworld-app-springboot-helloworld-project.apps-crc.testing/hello