Installing the OpenShift ‘oc’ Command-Line Interface on Windows Pro
OpenShift, developed by Red Hat, is a popular Kubernetes distribution that offers developer and operational tools to accelerate application development. One of essential tools provided by OpenShift is the oc
command-line interface (CLI). The oc
CLI is used to interact with OpenShift clusters, allowing users to perform tasks like creating and managing projects, starting builds, and deploying applications.
In this guide, I will take you through the steps required to install the oc
CLI on a Windows Pro machine.
Prerequisites:
Access to the Developer Sandbox provided by Red Hat
Step-by-step Guide:
1 — Download the oc
CLI
Go to the OpenShift web console, click the question mark icon in the upper right corner of the page to display the menu and click the Command line tools, to get to the oc
download page
Look for the oc
CLI zip file for windows, named Download oc
for Windows for x86_64 in the above screenshot. Click on the link to download the zip file.
2 — Extract the downloaded the zip file
Once the download is complete, navigate to the directory where the zip file was downloaded.
Right-click on the zip file and choose Extrat All.
Choose a destination folder for the extraction. I typically navigate to my home directory and create a folder named Utils. I then extract the contents into this foler. The path for this folder would be: C:\Users\Jimin Byun\Utils
3 — Add the oc
CLI to your system’s PATH:
After extracting, you’ll find the oc.exe file in the extracted directory.
To use the oc
command globally from the command prompt, you need to add its path to the system’s PATH variable.
Navigate to the Windows search bar, type in path, and the top result you should see will be Edit the system environment variables. Click this item.
This action will prompt the Environment Variables dialog box to appear. Under the User variables for username section, find the Path and variable and click Edit.
In the edit window appeared, cilck New, and then paste the path to the directory where oc.exe resides.
Click OK to close each of the windows.
4 — Verify the installation
Open a new Command Prompt or Windows PowerShell window. Type oc version
and press Enter. If installed correctly, you should see the version details of the oc
CLI displayed.
Conclusion.
Congratulations! You’ve successfully installed the OpenShift oc
CLI on your Windows Pro machine. You can now interact with OpenShift clusters and manage your projects more efficiently. For further assistance and learning more about oc
commands, consider refering to the official OpenShift documentation.
Reference
Mac Collins. (2023). Practical OpenShift for Developers — OpenShift 4. Udemy. Available at: https://www.udemy.com/course/openshift-for-developers. Accessed 31 Aug. 2023.