Thursday, 6 November 2025

How to Download and Use the OpenShift oc CLI on Windows

Our course you can check :-   Udemy course 


If you're working with OpenShift from a Windows machine, the oc CLI (OpenShift Client) is your gateway to managing clusters, deploying applications, and automating tasks. This guide walks you through downloading the oc binary, setting it up on Windows, and connecting to your OpenShift cluster.


✅ Step 1: Download the oc CLI for Windows

  1. Visit the official OpenShift CLI download page: ๐Ÿ‘‰ https://mirror.openshift.com/pub/openshift-v4/clients/ocp/

  2. Choose the version that matches your OpenShift cluster (e.g., 4.14.0) and download the Windows archive:

    • File name will look like: openshift-client-windows-4.14.0.zip

      or directly download from below

      https://console.redhat.com/openshift/downloads
      
      
  3. Extract the ZIP file to a folder, for example:



๐Ÿ› ️ Step 2: Add oc to Your System PATH

To use oc from any terminal window:

  1. Press Win + S, search for Environment Variables, and open Edit the system environment variables.

  2. Click Environment Variables.

  3. Under System variables, find and select Path, then click Edit.

  4. Click New and add the path to the folder where oc.exe is located: C:\OpenShiftCLI\

  5. Click OK to save and close all dialogs.

  6. Open a new Command Prompt or PowerShell window and test: oc version


๐Ÿ” Step 3: Log in to Your OpenShift Cluster

You’ll need the OpenShift API URL and a login token or credentials.

Option 1: Login with Token

  1. Open the OpenShift Web Console.
  2. Click your username (top right) → Copy Login Command.
  3. It will show a command like: oc login https://api.your-cluster.example.com:6443 --token=sha256~your-token-here
  4. Paste and run this command in your terminal.

Option 2: Login with Username/Password

oc login https://api.your-cluster.example.com:6443 -u your-username -p your-password


๐Ÿงช Step 4: Run OpenShift Commands

Now you're ready to interact with your cluster!

Examples:

oc get nodes
oc get pods -n my-namespace
oc new-project demo-project


๐Ÿงผ Optional: Create a Script for Quick Login

You can create a .bat or .ps1 script to automate login:

login-openshift.bat

@echo off
oc login https://api.your-cluster.example.com:6443 --token=sha256~your-token-here



๐ŸŽฏ Conclusion

With the oc CLI set up on your Windows system, you can now manage OpenShift clusters directly from your terminal. Whether you're deploying apps, managing resources, or automating tasks, the CLI gives you full control.

No comments:

Post a Comment