In this lesson, you will learn the step-by-step guide of how to install OpenShift cluster locally on a laptop or desktop using the OpenShift Local.
Understanding The Subject Matter
In the previous lesson, we discussed the different methods of how to install OpenShift container platform and we agreed we will start with installing the single node OpenShift cluster due to resources, hence, in this lesson, we are going to install OpenShift cluster using the OpenShif Local.
Openshift Local, formerly called the CodeReady container (CRC), can be installed on Linux, Windows, and Mac OS.
OpenShift local can only run with NetworkManager and on a hypervisor, just like the Kubernetes minikube, which runs only on a hypervisor.
To interact with OpenShift, we need an OpenShift client tool, one of which is the “OC” (OpenShift client). Incidentally, the OC is installed alongside the Openshift local.
The OpenShift local also needs a pull secrete to be able to get installed. One can easily open a Red hat developer account and use this link to get a pull secrete. It’s a very straight forward process. You can ask your questions below if you have any difficulty in getting your pull secrete.
Because I prefer to use Linux, being a Red Hat guy, I will be doing this installation on RHEL 9. This same installation can be done on the RHEL 8 and RHEL 7 systems. We already discussed the requirements for your hardware or VMs in the previous lesson. The requirements can also be seen in the diagram below.
Lets see the step by step guide of how to install OpenShift local on a Linux system.
ACTION TIME
Step By Step Guide Of How To Install OpenShift Local (CodeReady Container) On RHEL 9 / RHEL 8 /RHEL 7
***Preparing and installing the kvm hypervisor***
* For RHEL 9, you will have to install the KVM hypervisor
[root@snk ~]# dnf install qemu-kvm libvirt virt-install virt-viewer -y
Updating Subscription Management repositories.
Last metadata expiration check: 0:11:52 ago on Fri 15 Jul 2022 13:59:28.
Dependencies resolved.
================================================================================
.....................
*Start libvirtd
[root@sno ~]# systemctl start libvirtd
[root@sno ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; disabled; vendor>
Active: active (running) since Fri 2022-07-15 14:13:00 WAT; 2s ago
TriggeredBy: ● libvirtd-ro.socket
..................................
*For RHEL 8, since the full installation comes with libvirt, you will have to also install the libvirt additional packages.
[root@sno ~]# dnf install @virt -y
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 3.3 kB/s | 4.1 kB 00:01
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 747 B/s | 4.5 kB 00:06
Dependencies resolved.
..................................
* Restart libvirtd
[root@sno ~]# systemctl restart libvirtd
***Getting The Pull Secrete***
You can get the pull secrete using this link after you have created the Red Hat developer account.
***Installing OpenShift Local***
1. Download the latest version of OpenShift local/CRC
[root@sno ~]# wget https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz
--2022-07-14 13:06:20-- https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz
........................
2. Verify that the OpenShift local/CRC has been downloaded
[root@sno ~]# ls
anaconda-ks.cfg Desktop Downloads Music Public Videos
crc-linux-amd64.tar.xz Documents initial-setup-ks.cfg Pictures Templates
3. Extract the downloaded file
[root@sno ~]# tar xvf crc-linux-amd64.tar.xz
crc-linux-2.5.1-amd64/
crc-linux-2.5.1-amd64/LICENSE
crc-linux-2.5.1-amd64/crc
4. Verify that the file has been extracted.
[root@sno ~]# ls
anaconda-ks.cfg Desktop initial-setup-ks.cfg Public
crc-linux-2.5.1-amd64 Documents Music Templates
crc-linux-amd64.tar.xz Downloads Pictures Videos
*Make the file executable
[root@sno ~]# chmod +x crc-linux-2.5.1-amd64/crc
5. Since the extracted crc file is a binary file, we can easily install by copying or moving it to the /usr/local/bin directory
[root@sno ~]# cp crc-linux-2.5.1-amd64/crc /usr/local/bin
*you can verify the version of the CRC installed
[victor@sno ~]$ crc version
CRC version: 2.5.1+3d569b8
OpenShift version: 4.10.18
Podman version: 4.1.0
CRC should not run as root, hence, we need another user, preferably, a sudo user to run CRC. I already have a user with the name victor. I am going to make the user a sudo user and also add the user to the libvirt (hypervisor/kvm) group.
6. make the user, victor a sudo user and also add the user to the libvirt group
[root@sno ~]# usermod -aG libvirt victor
[root@sno ~]# usermod -aG wheel victor
[root@sno ~]# id victor
uid=1000(victor) gid=1000(victor) groups=1000(victor),10(wheel),981(libvirt)
7. logout and login as the user, victor or ssh into the server as the user, victor on the same terminal.
NB: its best not to switch user in this case (su – victor)
[root@sno ~]# ssh victor@localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:1b+fFpvcXKQU4MQUnvcqKbUKfgpKUj4CmG/1FeNOlks.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
victor@localhost's password:
[victor@sno ~]$
8. Initiate the OpenShift local/CRC setup
This setup will download the CRC bundle (VM image for the OpenShift cluster that will run in the KVM hypervisor).
[victor@sno ~]$ crc setup
CRC is constantly improving and we would like to know more about usage (more details at https://developers.redhat.com/article/tool-data-collection)
............................
INFO Using bundle path /home/victor/.crc/cache/crc_libvirt_4.10.18_amd64.crcbundle
INFO Checking if running as non-root
...............................
INFO Getting bundle for the CRC executable
INFO Downloading crc_libvirt_4.10.18_amd64.crcbundle
3.13 GiB / 3.13 GiB [----------------------------------------------------] 100.00%
...............................
Your system is correctly setup for using CRC. Use 'crc start' to start the instance
9. Start OpenShift local/CRC
starting CRC will prompt you to impute the pull secrete.
[victor@sno ~]$ crc start
INFO Checking if running as non-root
INFO Checking if running inside WSL2
.............................
CRC requires a pull secret to download content from Red Hat.
You can copy it from the Pull Secret section of https://console.redhat.com/openshift/create/local.
? Please enter the pull secret
...............................
INFO Creating CRC VM for OpenShift 4.10.18...
INFO Generating new SSH key pair...
INFO Generating new password for the kubeadmin user
INFO Starting CRC VM for OpenShift 4.10.18...
..................................
INFO Adding crc-admin and crc-developer contexts to kubeconfig...
Started the OpenShift cluster.
The server is accessible via web console at:
https://console-openshift-console.apps-crc.testing
Log in as administrator:
Username: kubeadmin
Password: W37tT-ziN3T-eE6VP-q6Yt9
Log in as user:
Username: developer
Password: developer
Use the 'oc' command line interface:
$ eval $(crc oc-env)
$ oc login -u developer https://api.crc.testing:6443
10. Verify the crc status
[victor@sno ~]$ crc status
CRC VM: Running
OpenShift: Running (v4.10.18)
Podman:
Disk Usage: 15.09GB of 32.74GB (Inside the CRC VM)
Cache Usage: 16.87GB
Cache Directory: /home/victor/.crc/cache
* if you try using the oc tool, it will not work because, you need to configure your shell just as the instruction was given in the last information in step 9 when we run the “crc start command”.
Let’s try it.
[victor@sno ~]$ oc
bash: oc: command not found...
11. set the oc path
[victor@sno ~]$ crc oc-env
export PATH="/home/victor/.crc/bin/oc:$PATH"
# Run this command to configure your shell:
# eval $(crc oc-env)
12. configure your shell to use oc
[victor@sno ~]$ eval $(crc oc-env)
*Now try the oc command again
[victor@sno ~]$ oc
OpenShift Client
This client helps you develop, build, deploy, and run your applications on any
OpenShift or Kubernetes cluster. It also includes the administrative
commands for managing a cluster under the 'adm' subcommand.
To familiarize yourself with OpenShift, login to your cluster and try creating a
sample application:
oc login mycluster.mycompany.com
oc new-project my-example
oc new-app django-psql-example
oc logs -f bc/django-psql-example
.............................
13. Login to the cluster as admin
[victor@sno ~]$ oc login -u kubeadmin -p W37tT-ziN3T-eE6VP-q6Yt9 https://api.crc.testing:6443
Login successful.
You have access to 64 projects, the list has been suppressed. You can list all projects with 'oc projects'
Using project "default".
14. We can test by getting some of the cluster information or services
*Test 1
[victor@sno ~]$ oc get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.217.4.1 <none> 443/TCP 23d
service/openshift ExternalName <none> kubernetes.default.svc.cluster.local <none> 23d
*Test 2
[victor@sno ~]$ oc get nodes
NAME STATUS ROLES AGE VERSION
crc-5nvrm-master-0 Ready master,worker 23d v1.23.5+3afdacb
15. Try logging in to the cluster as the user, developer too
[victor@sno ~]$ oc login -u developer https://api.crc.testing:6443
Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.
You don't have any projects. You can try to create a new project, by running
oc new-project <projectname>
Click Here To Watch Video On The Step By Step Guide Of How To Install OpenShift Cluster Locally
install OpenShift Locally
Your feedback is welcomed. If you love others, you will share with others
encountered problems during installation.
I get this error:
[kerberos5@server-crc ~]$ ssh kerberos5@localhost
Web console: https://server-crc:9090/ or https://10.0.2.16:9090/
Last login: Mon Apr 17 09:37:12 2023 from 192.168.56.146
[kerberos5@server-crc ~]$ crc setup
INFO Using bundle path /home/kerberos5/.crc/cache/crc_libvirt_4.12.9_amd64.crcbundle
INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
INFO Checking if running on a supported CPU architecture
INFO Checking minimum RAM requirements
INFO Checking if crc executable symlink exists
INFO Checking if Virtualization is enabled
INFO Setting up virtualization
You need to enable virtualization in BIOS
i use virtualbox 7
vm with centos8
i enabled VT on bios and on virtulabox but not work… How can I solve the problem?
Make sure you have disabled Hyper-V virtualization in Windows, enabled any virtualization engine settings in VirtualBox for the VM specifically, and disable Memory Integrity under Windows 11 Core Isolation.
How to disabled the hyper -v virtualization in windows and disable Memory Integrity under Windows 11 Core Isolation.
Please confirm below user is mandate, This user is not available in my local
usermod -aG libvirt victor
The user is just a user I created. Its not mandatory. You can use any user available on your system.
Hello Victor/tekneed team,
Reference to your youtube video of CRC setup,https://www.youtube.com/watch?v=6vafQzAbdOo
I need your help how to reset CRC setup, is there any video or cmd guide to reset crc, in order to practice again from scratch, plz reply
Hi Syed,
CRC can become unstable sometimes because its a SNC and the keys may have expired. Why not delete it (crc delete), and recreate (crc setup) & (crc start) so you can start from scratch.