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
Visit the official OpenShift CLI download page: ๐ https://mirror.openshift.com/pub/openshift-v4/clients/ocp/
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 belowhttps://console.redhat.com/openshift/downloads
- File name will look like:
Extract the ZIP file to a folder, for example:
๐ ️ Step 2: Add oc to Your System PATH
To use oc from any terminal window:
Press
Win + S, search for Environment Variables, and open Edit the system environment variables.Click Environment Variables.
Under System variables, find and select
Path, then click Edit.Click New and add the path to the folder where
oc.exeis located: C:\OpenShiftCLI\Click OK to save and close all dialogs.
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
- Open the OpenShift Web Console.
- Click your username (top right) → Copy Login Command.
- It will show a command like: oc login https://api.your-cluster.example.com:6443 --token=sha256~your-token-here
- 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:
๐งผ Optional: Create a Script for Quick Login
You can create a .bat or .ps1 script to automate login:
login-openshift.bat
๐ฏ 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