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: Comprehensive Guide: oc vs kubectl CLI

Hereโ€™s a comprehensive guide comparing the oc (OpenShift CLI) and kubectl (Kubernetes CLI) commands, focusing on their differences, similarities, and real-world usage. This is especially useful for OpenShift developers or admins coming from Kubernetes backgrounds.


๐Ÿ“˜ Comprehensive Guide: oc vs kubectl CLI

Aspectoc (OpenShift CLI)kubectl (Kubernetes CLI)
DefinitionCLI tool for managing OpenShift resources and clustersCLI tool for managing Kubernetes resources and clusters
Default ClusterTargets OpenShift (Red Hat Kubernetes platform)Targets any CNCF-compliant Kubernetes cluster
InstallationInstalled with OpenShift tools or CRCComes bundled with most Kubernetes distributions
Resource AccessSupports all Kubernetes APIs + OpenShift APIs (e.g., Build, Route, ImageStream)Supports only Kubernetes-native APIs
CustomizationIncludes extended functionality and OpenShift-specific templatesNo built-in support for OpenShift-only resources
LoginUses oc login with OpenShift OAuthUses kubectl config or kubeconfig files
CompatibilityFully supports kubectl commands as aliasesCannot access OpenShift-only resources

โœ… Similarities Between oc and kubectl

FeatureExample Command (same for both)Description
Get Podsoc get pods / kubectl get podsLists pods in current namespace
Describe Resourceoc describe pod <name> / kubectl describe pod <name>Detailed pod description
Apply YAMLoc apply -f app.yaml / kubectl apply -f app.yamlApply resource configuration
Delete Resourcesoc delete pod <name> / kubectl delete pod <name>Delete a resource
Logsoc logs <pod> / kubectl logs <pod>Stream logs from a container
Port-forwardoc port-forward svc/myapp 8080:80Forward local port to a service
Execoc exec -it <pod> -- /bin/bashGet shell access to a pod

โœ… Fact: Every valid kubectl command is also valid in oc.


๐Ÿ”ด Differences: oc Adds OpenShift-Specific Features

CommandOnly in ocPurpose
oc new-appYesRapid app deployment from source/image
oc new-projectYesCreate a new OpenShift project (namespace)
oc admYesOpenShift admin utility commands
oc rolloutExtendedManage OpenShift-specific rollouts
oc statusYesVisual overview of current project
oc whoamiYesCheck current OpenShift user
oc get routeYesView OpenShift routes (external access)
oc import-imageYesImport images into OpenShift image streams
oc policyYesRBAC management for OpenShift
oc start-buildYesTrigger OpenShift BuildConfig
oc logs -f bc/<buildConfig>YesStream logs from OpenShift build

โš ๏ธ kubectl does not support OpenShift-specific resources like Route, BuildConfig, DeploymentConfig, ImageStream.


๐Ÿงช Example: Deploying a Sample App

Using kubectl (Kubernetes way):

kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
Code language: CSS (css)

Using oc (OpenShift way):

oc new-app nodejs~https://github.com/sclorg/nodejs-ex.git
oc expose svc/nodejs-ex
Code language: JavaScript (javascript)

OpenShift simplifies workflows with oc new-app and oc expose.


๐Ÿ‘ฉโ€๐Ÿ’ป Example: Working with Projects/Namespaces

# Create and switch in OpenShift
oc new-project myapp

# Create namespace in Kubernetes
kubectl create namespace myapp
kubectl config set-context --current --namespace=myapp
Code language: PHP (php)

โš™๏ธ oc adm (Admin Commands Exclusive to OpenShift)

CommandPurpose
oc adm diagnosticsRun cluster diagnostics
oc adm topView resource usage like kubectl top
oc adm policy add-role-to-userManage RBAC easily
oc adm groupsManage OpenShift user groups
oc adm node-logsView node logs in OpenShift
oc adm drainDrain node (similar to kubectl drain)

๐Ÿง  When to Use What?

Use CaseRecommended CLI
Basic Kubernetes operationskubectl or oc
OpenShift templates, routes, and buildsoc only
Admin tasks on OpenShift (RBAC, node mgmt)oc adm
Scripting across clusters (K8s generic)kubectl
Using CRC or OpenShift Onlineoc preferred

๐Ÿ“Œ Summary Table

Command Typekubectl Supportoc Support
Kubernetes Resourcesโœ… Yesโœ… Yes
OpenShift ResourcesโŒ Noโœ… Yes
CLI Alias of Each Otherโœ… oc supports all kubectlโœ… Yes
Admin CommandsโŒ Limitedโœ… Full (oc adm)
Developer ProductivityโŒ No templatingโœ… Powerful templates, routes, builds

๐Ÿ’ก Tip: You can always alias kubectl to oc if you’re using OpenShift full-time:

alias kubectl='oc'
Code language: JavaScript (javascript)

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

List of all Job Roles, Job Titles in Software and IT Companies

The software and IT industry is home to a diverse array of job roles and titles, reflecting the dynamic and ever-evolving nature of technology. From core technical…

Read More

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 Install & Configurations using OpenShift Local in windows laptops/desktops

Below is the 100% correct and updated step-by-step guide to install and configure OpenShift Local (aka CRC) on Windows 10/11 laptops or desktops using the correct crc…

Read More

Openshift: How to configure Azure openshift ARO with Custom Domain

Step-by-Step Guide: Configuring Azure Red Hat OpenShift (ARO) with a Custom Domain Setting up a custom domain for your ARO cluster involves both Azure and DNS provider…

Read More

Openshift: Lab 10 – View performance information using the OpenShift web console

Rajesh Kumar Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at…

Read More

Openshift: How to add Helm Repository in Openshift

Adding a Helm repository in OpenShift is a common step to manage and deploy Helm charts in your OpenShift cluster. OpenShift supports Helm CLI out of the…

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