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

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
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x