MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

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 Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Deploying Nexus Certificate Manager (CM) and Protocol Gateway (PGWY) on Kubernetes

Step-by-step tutorial, written from an actual deployment of Certificate Manager 8.15.1-1 (CF server image 8.15.1-1, PGW image 8.15.1-1) on a 2-node kubeadm cluster. Status of this document (2026-11-12) Steps 1-8 were executed…

Read More

Kubernetes Ingress Controller using Path-Based Routing: Complete Hands-On Lab with Calico VXLAN

Scope: Self-managed Kubernetes on two AWS EC2 Ubuntu nodes; install the community ingress-nginx v1.15.1 bare-metal/NodePort manifest, repair cross-node Calico networking, deploy two NGINX versions behind ClusterIP Services, configure path-based routing…

Read More

Kubernetes storageclassย using OpenEBS Local PV HostPath โ€” Complete Step-by-Step Kubernetes Tutorial

Dynamic storage provisioner: openebs.io/localLab platform: Self-managed Kubernetes v1.35.10 on Ubuntu Linux (kubeadm or other manual installation)OpenEBS release referenced: OpenEBS 4.6.2 (HostPath engine v4.6.0), current as checked on November 12, 2026Lab…

Read More

Kubernetes storageclass using Rancher Local Path Provisioner: Complete Step-by-Step Kubernetes Tutorial

Goal: Automatically provision hostPath-backed PersistentVolumes (PVs) for a 3-replica StatefulSet on a self-managed Ubuntu Kubernetes cluster, without hand-writing a PV or a PVC manifest. Lab setting Value Kubernetes v1.35.10 (self-managed / kubeadm-style installation)…

Read More

Kubernetes ReplicaSet Explained: API Resource, YAML Example, and Use Cases

Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have…

Read More

Debugging Terraform + Helm Drift on EKS: Failure Behaviours and Fixes

A field tutorial based on a real incident removing a stale CriticalAddonsOnly toleration from metrics-server and KEDA on EKS Auto Mode clusters managed by Terraform Cloud (TFC) + the eks-blueprints-addons module. TL;DR We tried to…

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