Using RedHat CodeReady Containers (CRC), we can easily install latest version of OpenShift cluster on laptop, desktop or in a virtual machine. In this tutorial, we will demonstrate how to setup single node openshift cluster on RHEL 8 system with crc. This type of openshift cluster is used only for testing and development purpose, it is not recommended for the production use.

Minimum System Requirement for OpenShift based on CRC
  • Freshly Installed RHEL 8
  • KVM hypervisor
  • 4 CPUs (or vCPUs)
  • 8 GB RAM
  • 40 GB Free space on /home

I am assuming above requirements are already fulfilled on your RHEL 8 system. In my case I have installed RHEL 8 with GUI and KVM hypervisor during the installation. In case you have minimal installation of RHEL 8 then first setup kvm on your system. Let’s jump into the installation steps,

Step1) Download Latest Version of CRC

Open the terminal and run the following wget command,

$ wget https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz

Sample output of above command would be

download-lastest-crc-rhel8

Step 2) Extract Downloaded CRC archive & copy its binary

Once crc compressed archive file is downloaded, extract it using below tar command,

$ sudo tar -xpvf crc-linux-amd64.tar.xz

Copy the crc binary in /usr/local/bin directory

$ cd crc-linux-1.22.0-amd64/
$ sudo cp crc /usr/local/bin/

Now verify the crc version by running following command:

$ crc version
CodeReady Containers version: 1.22.0+6faff76f
OpenShift version: 4.6.15 (embedded in executable)
$

Step 3) Start OpenShift 4.x Deployment using CRC

Run ‘crc setup’ command to download crc virtual machine (crc.qcow2)  which is around 10.83 GB.

$ crc setup

crc-setup-rhel8

Once the ‘crc  setup’ is completed successfully then download the pull secret which will be used during the openshift cluster startup.

To download the pull secret login to below Redhat portal,

https://cloud.redhat.com/openshift/install/crc/installer-provisioned

Download-Pull-Secret-RedHat-Portal

Now finally run below command to start Openshift cluster,

Syntax:

$ crc start -p <path-of-pull-secret-file>

$ crc start -p pull-secret

Once above command is executed successfully, we will get the following output. In the output we have ‘kubeadmin’ credentials and cluster URL. Make a note of it we will use them later.

crc-start-kubeadmin-credentials-rhel8

To connect to OpenShift Cluster, set the following environment by executing:

$ crc oc-env
export PATH="/home/sysadmin/.crc/bin/oc:$PATH"
# Run this command to configure your shell:
# eval $(crc oc-env)
$

Copy above output and paste it in ‘.bashrc’ file at the end as shown below:

[sysadmin@openshift-rhel8 ~]$ vi .bashrc
…………………
export PATH="/home/sysadmin/.crc/bin/oc:$PATH"
# Run this command to configure your shell:
eval $(crc oc-env)
……………………

Save & close the file

Source the ‘.bashrc’ file to make above changes into the affect.

$ source .bashrc

Step 4) Connect and verify OpenShift Cluster

Before connecting to cluster, let first enable bash autocompletion feature. Run following commands,

$ oc completion bash > oc_bash_completion
$ sudo cp oc_bash_completion /etc/bash_completion.d/

Logout and login again.

Now, it’s time to connect to Openshift cluster, run below command, (This was there in crc start command output)

$ oc login -u kubeadmin -p APBEh-jjrVy-hLQZX-VI9Kg https://api.crc.testing:6443

Output of above command would be,

Login-OpenShift-Cluster-Kubeadmin-RHEL8

Above output confirms that ‘kubeadmin’ is able to login to the cluster successfully.

Run following oc command to verify the cluster details

$ oc get nodes
$ oc cluster-info
$ oc get clusteroperators

OpenShift-Cluster-Details-RHEL8

To test this cluster, let’s deploy nginx based application, run beneath commands,

$ oc new-app --name nginx-app --docker-image=nginx
$ oc get deployment
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
nginx-app   1/1     1            1           2m2s
$ oc get pods
NAME                         READY   STATUS    RESTARTS   AGE
nginx-app-6d7c86dfd7-b6mvz   1/1     Running   0          2m4s
$
$ oc expose service nginx-app
route.route.openshift.io/nginx-app exposed
$ oc get route
NAME      HOST/PORT            PATH   SERVICES    PORT   TERMINATION   WILDCARD
nginx-app nginx-app-default.apps-crc.testing nginx-app 80-tcp         None

[sysadmin@openshift-rhel8 ~]$

Now try to access the application using curl command,

$ curl nginx-app-default.apps-crc.testing

curl-nginx-app-openshift-rhel8

Perfect, above confirms that nginx based application has been deployed successfully on OpenShift cluster.

To Access OpenShift Web console, run

$ crc console

Above will open web browser and we will get OpenShift GUI login screen , Use the kubeadmin and its credentials

OpenShift-WebConsole-Login-RHEL8

After Entering the credentials, following dashboard will be presented

OpenShift-GUI-Dashboard-RHEL8

Great, above screen confirms that OpenShift Web GUI also is working fine.

Troubleshooting

To stop the cluster, run

$ crc stop

To Start the cluster again, run

$ crc start

To Terminate the cluster, run

$ crc stop
$ crc delete -f
$ crc cleanup

That’s all from this tutorial, I hope it helps you to setup single node openshift cluster on RHEL 8 system. Please don’t hesitate to share your feedback and comments.

Also Read : How to Setup NGINX Ingress Controller in Kubernetes

The post How to Setup Single Node OpenShift Cluster on RHEL 8 first appeared on LinuxTechi.