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

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

Fearture of Kubernetes Deployment Note:ReplicaSets = Replication+Controller in the Deployment Kubernetes Deployement Strategy Type of deployment .spec.strategy specifies the strategy used to replace old Pods by new…

Read More

Understanding Authentication & Authorization in kubernetes

Authentication – How User’s access should be allowed? The process or action of verifying the identity of a user or process.Authorization – What Access and till what…

Read More

Troubleshooting Guide to Resolving 500 Errors in Kubernetes Production Environments

Source – https://github.com/rajeshkumarin/k8s-500-prod-issues ๐Ÿ“˜ Scenario #1: Zombie Pods Causing NodeDrain to HangCategory: Cluster ManagementEnvironment: K8s v1.23, On-prem bare metal, Systemd cgroupsScenario Summary: Node drain stuck indefinitely due…

Read More

List of Commands troubleshoot networking in Kubernetes

2024 Notes Troubleshooting networking in Kubernetes can sometimes be complex due to the distributed nature of containerized applications. Below is a list of commands with explanations to…

Read More

Helm Lab โ€“ 4: Creating and Packaging a Helm Chart

Windows Commands Linux Commands 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…

Read More

List of Popular Tools and Applications in Kubernetes ecosystem

K8s Cluster Management kubespray – Deploy a Production Ready Kubernetes Cluster kops – kops helps you create, destroy, upgrade and maintain production-grade, highly available, Kubernetes clusters from the command…

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