Download and Set-up OC with Kubectl OC Compatibility and PATH on Linux

Mindwatering Incorporated

Author: Tripp W Black

Created: 05/25 at 10:40 PM

 

Category:
RH OpenShift
Install

Tasks:
a. Download oc binary.
b. Copy to install location.
c. Setup shell $PATH and kubectl alias for oc.

Note:
- If you have an old version of oc and kubectl already installed, remove or replace them. Older versions of oc will be missing newer features of OCP.



A. Download the oc Binary:
1a. Download from the public mirror:
mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz

1b. Login to the Red Hat Downloads area: access.redhat.com/downloads/content/
(Login with your Red Hat ID)

2. Navigate to OpenShift Container Platform downloads page.
- Product Variant: <select architecture>
- Version: <select version, e.g. 4.20>
- Locate the entry: OpenShift v.4.nn Linux Clients, click Download Now (button).



B. Transfer to the administrative workstation.
1. Transfer the downloaded tar file.
- Use OCP, Filezilla, or your preferred method.
- Transfer to the /home/<myadminid> location for transfer

2. Login to the workstation, uncompress, and move the oc binary to the /usr/local/bin/ folder (or desired location on $PATH)
Login:
$ ssh myadminid@occli.mindwatering.net
<enter pwd if not using private key>

Uncompress the file:
# cd /home/myadminid
# ls *.gz
<confirm oc archive file is there>

# tar xvf oc.tar.gz
<wait a second>

Move the oc binary and the kubectl binary into place:
$ sudo mv oc kubectl /usr/local/bin/
<enter pwd>



C. Set-up Shell for Editor and Alias.
1. Edit the .bashrc file for the current user, and append the following, as needed/desired:
$ vi ~/.bashrc
...
# Add oc to your PATH if /usr/local/bin was not used
export PATH=$PATH:/mycustompath/to/oc

# Set default editor for oc edit commands to vi/vim
export EDITOR=vim

# Enable kubectl compatibility mode
alias kubectl=oc

<esc>:wq (to save)



previous page

×