Comparing kubectl and oc: Unlocking the Power of Kubernetes and OpenShift CLI

When working with Kubernetes, the kubectl command-line tool is the industry standard for managing clusters. However, if you’re using OpenShift, you also have access to the oc CLI, which extends kubectl with additional, OpenShift-specific commands and functionalities. In this post, we’ll compare kubectl and oc, highlight the extra commands available in oc, and discuss how these differences can boost your productivity in managing containerized environments.


1. Introduction

Both kubectl and oc allow you to interact with your Kubernetes clusters. While kubectl is the primary tool for Kubernetes, the oc CLI enhances this functionality by integrating OpenShift-specific features such as application lifecycle management, source-to-image (S2I) builds, and extended security controls. Understanding the differences between these tools can help you choose the right command set for your workflow.


2. Overview of kubectl

kubectl is the command-line tool that allows you to deploy, manage, and troubleshoot applications running on Kubernetes. Key features include:

  • Resource Management:
    Create, update, delete, and query Kubernetes resources like Pods, Deployments, Services, and more.
  • Declarative Configuration:
    Apply configuration changes using YAML files.
  • Debugging Tools:
    Commands such as kubectl logs, kubectl describe, and kubectl exec facilitate troubleshooting.
  • Consistent API:
    Works uniformly across different Kubernetes distributions.

Example Command:

kubectl get pods

3. Overview of oc (OpenShift CLI)

The oc CLI is built on top of kubectl and provides all of its functionalities, plus additional OpenShift-specific commands. It’s designed to simplify management in OpenShift clusters with extra features for:

  • Project Management:
    Enhanced commands for managing OpenShift projects (namespaces) such as oc new-project and oc project.
  • Application Deployment:
    Integrated workflows for Source-to-Image (S2I) builds, which streamline container image creation directly from source code.
  • Routing and Networking:
    Commands to manage routes, which are unique to OpenShift for exposing applications externally.
  • User and Security Management:
    Additional commands for handling OpenShift-specific security and user management tasks.
  • Enhanced Resource Handling:
    Built-in support for template processing and advanced configuration management.

Example Command:

oc new-app https://github.com/openshift/ruby-hello-world.git

4. Extra Commands Available in oc

The oc CLI includes several extra commands not found in kubectl, such as:

  • Project and User Management:
    • oc new-project [project-name] – Quickly create a new project.
    • oc whoami – Display the current user.
  • Source-to-Image (S2I):
    • oc new-app – Automatically build and deploy an application from source code using S2I.
  • Route Management:
    • oc expose svc/[service-name] – Create a route to expose a service externally.
  • Template Processing:
    • oc process – Process OpenShift templates to generate configuration files.
  • Enhanced Rollout and Deployment Commands:
    • oc rollout – Manage and monitor rollout status, pause, and undo deployments.

These additional commands simplify many common tasks in OpenShift, making it easier for developers and DevOps teams to deploy and manage applications in an enterprise environment.


5. Comparison: kubectl vs. oc

Featurekubectloc (OpenShift CLI)
Core FunctionalityManages Kubernetes resources.Extends kubectl with OpenShift-specific commands.
Project ManagementUses namespaces; manual management.Simplified project commands (oc new-project, oc project).
Application DeploymentUses YAML manifests and kubectl apply.Integrated S2I builds and oc new-app for rapid deployment.
RoutingNot available; requires external tools.Built-in route management for external access.
Security ManagementBasic RBAC controls.Enhanced security commands tailored for OpenShift.
Template ProcessingNot included.oc process for handling OpenShift templates.

6. Conclusion

Both kubectl and oc are powerful tools for managing containerized environments. While kubectl provides a solid foundation for Kubernetes management, the oc CLI extends this functionality with additional features that are crucial for OpenShift environments. The extra commands in oc, such as project management, S2I, and route configuration, offer significant advantages in terms of ease of use and efficiency—especially for enterprise deployments.

Your choice of tool will depend on your environment: use kubectl for general Kubernetes tasks and switch to oc when working in an OpenShift environment to take advantage of its enriched feature set.


7. 🤝 Connect With Us

Are you looking for certified professionals or need expert guidance on managing your Kubernetes or OpenShift clusters? We’re here to help!

🔹 Get Certified Candidates: Hire skilled professionals with deep expertise in Kubernetes and OpenShift.
🔹 Project Consultation: Receive hands‑on support and best practices tailored to your environment.

📞 Contact Us Now
💼 Discuss Your Project

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top