Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Openshift: Lab 5 – Install an application from a source code using the oc CLI tool

Lab 5 summary

This lab teaches how to use the oc CLI from your local machine to deploy an application into OpenShift Developer Sandbox from source code stored in GitHub. OpenShift uses oc new-app to detect the source, select/create the builder workflow, build a container image, create the app resources, and then you expose it with a Route.

Sample application used

https://github.com/openshift/ruby-hello-world.git#beta4
Code language: JavaScript (javascript)

Main command from the lab:

oc new-app https://github.com/openshift/ruby-hello-world.git#beta4
Code language: JavaScript (javascript)

The expected created resources include:

imagestream.image.openshift.io "ruby-22-centos7" created
imagestream.image.openshift.io "ruby-hello-world" created
buildconfig.build.openshift.io "ruby-hello-world" created
deployment.apps "ruby-hello-world" created
service "ruby-hello-world" created
Code language: CSS (css)

The lab then tells you to expose the service:

oc expose service/ruby-hello-world

Expected output:

route.route.openshift.io/ruby-hello-world exposed

Main flow

StepActionCommand / UI
1Open Developer Sandbox web consoleBrowser
2Get CLI login command? icon → Command Line tools → Copy login command
3Display tokenClick Display Token
4Log in from terminalPaste copied oc login --token=... --server=...
5Deploy app from Git sourceoc new-app https://github.com/openshift/ruby-hello-world.git#beta4
6Track build logsoc logs -f buildconfig/ruby-hello-world
7Expose appoc expose service/ruby-hello-world
8Open appTopology view → URL/open icon
9Delete appoc delete all -l app=ruby-hello-world

Clean CLI version of Lab 5

# Log in using the token command copied from OpenShift web console
oc login --token=<your-token> --server=<your-api-server>

# Confirm login
oc whoami

# Check current project
oc project

# Deploy app from GitHub source code
oc new-app https://github.com/openshift/ruby-hello-world.git#beta4

# Watch the build logs
oc logs -f buildconfig/ruby-hello-world

# Check created resources
oc get all

# Expose the service as a route
oc expose service/ruby-hello-world

# Get route
oc get route ruby-hello-world

# Test the route
curl -I http://$(oc get route ruby-hello-world -o jsonpath='{.spec.host}')

# Delete application resources
oc delete all -l app=ruby-hello-world
Code language: PHP (php)

Important correction

The PDF text says the selector option is -1, but that is a typo. The actual oc selector flag is lowercase -l, meaning “label selector.”

Correct:

oc delete all -l app=ruby-hello-world
Code language: JavaScript (javascript)

Incorrect:

oc delete all -1 app=ruby-hello-world
Code language: JavaScript (javascript)

The command shown in the PDF is correct, but the explanatory sentence has the typo.

Difference from earlier labs

LabMethodToolExample
Lab 2Source code from GitHubWeb consolePython/Django source app
Lab 3Container imageWeb consoleParksMap image
Lab 4Container imageoc CLIGreeter image
Lab 5Source code from GitHuboc CLIRuby hello-world source app

So yes: Lab 5 is basically the CLI version of Lab 2, while Lab 4 was the CLI version of Lab 3.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Best DevOps Tools in 2024

here’s a clear, structured breakdown of the Best DevOps Tools (grouped by categories), so you can use it for learning, training, or posts. 🚀 Best DevOps Tools…

Read More

OpenShift Tutorial – Deploy and Access Your First Applications using OpenShift Local

How to install oc? OpenShift: How to Install OpenShift CLI oc How to login? Login to the Openshift using Web Console and CLI using oc Copy the admin…

Read More

OpenShift Lab 14: Setting Up and Using OpenShift Serverless Functions on OpenShift Local

Lab Objective In this lab, you will install and use OpenShift Serverless Functions on OpenShift Local. You will create a simple Node.js serverless function, deploy it to…

Read More

OpenShift Lab 13: Deploy a Java Spring Boot Application with MySQL Using the OpenShift Web Console

Lab Objective In this lab, you will deploy a Java Spring Boot application on OpenShift using the OpenShift web console. You will deploy two components: The Java…

Read More

OpenShift Lab 12: Deploy an Application from an Existing Container Image Using the OpenShift Web Console

Lab Objective In this lab, you will deploy an application on OpenShift from an existing container image. This lab is different from building an application from source…

Read More

OpenShift: How to Install OpenShift CLI oc

Option – 1 – REDHAT Websites URL – https://access.redhat.com/downloads/content/290/ver=4.18/rhel—9/4.18.11/x86_64/product-software Option – 2 – OKD Websites The OKD (Origin Community Distribution of Kubernetes for OpenShift) is the open-source…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Skylar Bennett
Skylar Bennett
18 days ago

The tutorial covers source code deployment with the oc CLI effectively, but it would be helpful to include some considerations for maintaining these workflows at scale. In production environments, teams often focus on reducing build times through dependency caching, implementing vulnerability scans for generated images, and establishing clear artifact promotion processes. Discussing how these deployments fit into GitOps-based delivery models would also provide readers with a better understanding of managing consistent releases across multiple environments.

1
0
Would love your thoughts, please comment.x
()
x