OKD is an Open Source implementation of Red Hat OpenShift. In a nutshell, it is the community distribution of Kubernetes optimized for developing, deploying, and managing container-based applications. Openshift gives you a self-service platform to create, modify, and deploy applications on demand.

We will use CodeReady Containers (CRC) which is a tool from Red Hat that enables you to to deploy a local OpenShift cluster in your laptop, server, or Desktop workstation. CRC provide a streamlined experience for developing and testing applications in OpenShift without the need to build a full-scale production cluster environment.

Minimum hardware requirements:

Below are the minimum system requirements for running CRC in your local system:

  • CPU: Multi-core processor with min of 2 cores.
  • RAM: At least 10GB of RAM (16GB or more is recommended).
  • Disk Space: At least 35GB of free disk space.
  • Virtualization: Your system CPU should support hardware virtualization (KVM)

For multiple nodes OpenShift cluster deployment check out the article below:

Before you begin the setup, confirm if your host support hardware virtualization.

grep -Ec '(vmx|svm)' /proc/cpuinfo

If you get an output it means your system has support for hardware virtualization.

Ezoic

Ezoic

Step 1: Disable systemd-networkd

If you have systemd-networkd service active you need to disable since CRC doesn’t support it as network manager. Follow the article in the link below for the steps to disable systemd-networkd and enable NetworkManager.

Step 2: Download CRC on Ubuntu

After disabling systemd-networkd and switching to NetworkManager, install dependencies.

sudo apt update
sudo apt install wget vim libvirt-daemon-system qemu-kvm libvirt-daemon network-manager

If you don’t have a non root user create one.

useradd -m crc -s /bin/bash
passwd crc
usermod -aG wheel crc||usermod -aG sudo crc
echo "crc ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/crc
su - crc

Download CRC binary archive.

wget https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz

Extract the file after being downloaded locally.

tar xvf crc-linux-amd64.tar.xz

Move the resulting binary file to a location in your $PATH.

sudo mv crc-linux-*-amd64/crc /usr/local/bin
sudo rm -rf crc-linux-*-amd64/

Validate the installation by checking the version of CRC.

$ crc version
CRC version: 2.38.0+25b6eb
OpenShift version: 4.15.17

Data collection can be enabled or disabled with the following commands:

#Enable
crc config set consent-telemetry yes

#Disable
crc config set consent-telemetry no

Step 3: Run OpenShift on Ubuntu using CRC

Disable systemd units check:

$ crc config set skip-check-daemon-systemd-unit true
Successfully configured skip-check-daemon-systemd-unit to true

$ crc config set skip-check-daemon-systemd-sockets true
Successfully configured skip-check-daemon-systemd-sockets to true

Run the crc setup command to deploy a local OpenShift cluster on Ubuntu Linux.

Ezoic

crc setup

A setup will perform pre-checks, install dependencies and perform necessary configurations.

INFO Using bundle path /home/crc/.crc/cache/crc_libvirt_4.15.17_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 if crc executable symlink exists
INFO Checking minimum RAM requirements
INFO Check if Podman binary exists in: /home/crc/.crc/bin/oc
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Installing libvirt service and dependencies
INFO Using root access: Installing virtualization packages
INFO Checking if user is part of libvirt group
INFO Checking if active user/process is currently part of the libvirt group
You need to logout, re-login, and run crc setup again before the user is effectively a member of the 'libvirt' group.

When requested to re-login do so:

logout

Login back and run the setup again.

crc setup

The setup process should progress as expected.

INFO Using bundle path /home/ubuntu/.crc/cache/crc_libvirt_4.15.17_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 if crc executable symlink exists
INFO Checking minimum RAM requirements
INFO Check if Podman binary exists in: /home/ubuntu/.crc/bin/oc
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Checking if user is part of libvirt group
INFO Checking if active user/process is currently part of the libvirt group
INFO Checking if libvirt daemon is running
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Checking crc daemon systemd service
WARN Skipping above check...
INFO Checking crc daemon systemd socket units
WARN Skipping above check...
INFO Checking if AppArmor is configured
INFO Updating AppArmor configuration
INFO Using root access: Updating AppArmor configuration
INFO Using root access: Changing permissions for /etc/apparmor.d/libvirt/TEMPLATE.qemu to 644
INFO Checking if systemd-networkd is running
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists
INFO Writing Network Manager config for crc
INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf
INFO Using root access: Changing permissions for /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf to 644
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl reload NetworkManager
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
INFO Writing dnsmasq config for crc
INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/dnsmasq.d/crc.conf
INFO Using root access: Changing permissions for /etc/NetworkManager/dnsmasq.d/crc.conf to 644
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl reload NetworkManager
INFO Checking if libvirt 'crc' network is available
INFO Setting up libvirt 'crc' network
INFO Checking if libvirt 'crc' network is active
INFO Starting libvirt 'crc' network
INFO Checking if CRC bundle is extracted in '$HOME/.crc'
INFO Checking if /home/ubuntu/.crc/cache/crc_libvirt_4.15.17_amd64.crcbundle exists
INFO Getting bundle for the CRC executable
INFO Downloading bundle: /home/ubuntu/.crc/cache/crc_libvirt_4.15.17_amd64.crcbundle...
4.64 GiB / 4.64 GiB [------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 82.18 MiB/s
INFO Uncompressing /home/ubuntu/.crc/cache/crc_libvirt_4.15.17_amd64.crcbundle
crc.qcow2:  20.43 GiB / 20.43 GiB [----------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
oc:  149.79 MiB / 149.79 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
Your system is correctly setup for using CRC. Use 'crc start' to start the instance

Start the instance that powers OpenShift cluster

crc start

You will be asked to input pull secret:

INFO Using bundle path /home/ubuntu/.crc/cache/crc_libvirt_4.15.17_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 if crc executable symlink exists
INFO Checking minimum RAM requirements
INFO Check if Podman binary exists in: /home/ubuntu/.crc/bin/oc
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Checking if user is part of libvirt group
INFO Checking if active user/process is currently part of the libvirt group
INFO Checking if libvirt daemon is running
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Checking crc daemon systemd socket units
WARN Skipping above check...
INFO Checking if AppArmor is configured
INFO Checking if systemd-networkd is running
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
INFO Checking if libvirt 'crc' network is available
INFO Checking if libvirt 'crc' network is active
INFO Loading bundle: crc_libvirt_4.15.17_amd64...
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

Get the pull secret from Red Hat OpenShift Portal.

crc install 03

Paste downloaded secret contents to continue with the installation.

? Please enter the pull secret <PASTE-PULL-SECRET-FROM-REDHAT-PORTAL>

You will get cluster access details once it’s running.

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: yHhxX-fqAjW-8Zzw5-Eg2jg

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

Login to cluster

Ezoic

 eval $(crc oc-env)
oc login -u developer https://api.crc.testing:6443

Checking VMN created.

$ sudo virsh list
Id Name State
----------------------
1 crc running

Step 4: Using crc commands

To adjust VM instance CPU count run:

crc config set cpus <number>

For memory change use:

# must be greater than or equal to '10752'
crc config set memory <number-in-mib>

Display status of the OpenShift cluster

crc status

Get IP address of the running OpenShift cluster

$ crc ip
192.168.130.11

Access OpenShift console by running:

crc console

Accept SSL certificate warnings.

crc install 04

Proceed by accepting risk.

crc install 05

Use the username and password given after installation to login.

Ezoic
crc install 06Ezoic

 You can also get credentials from the terminal for developer and kubeadmin users:

Ezoic
crc console --credentials

To stop the instance run the commands:

crc stop

If you want to permanently delete the instance, use:

crc delete

Step 5: Setup the oc CLI environment

Let’s add oc executable our system’s PATH:

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

$ vim ~/.bashrc
export PATH="/home/$USER/.crc/bin/oc:$PATH"
eval $(crc oc-env)

Logout and back in to validate it works.

$ exit

Check oc binary path after getting in to the system.

Ezoic
$ which oc
~/.crc/bin/oc/oc

$ oc get nodes
NAME                 STATUS   ROLES           AGE   VERSION
crc-9jm8r-master-0   Ready    master,worker   21d   v1.24.0+9546431

Confirm this works by checking installed cluster version

oc get clusterversion

Login as developer user.

crc console --credentials
oc login -u developer https://api.crc.testing:6443

Login as the kubeadmin user and run the following command:

Ezoic
$ oc config use-context crc-admin
$ oc whoami
kubeadmin

To log in to the registry as that user with its token, run:

oc registry login --insecure=true

List cluster operators by running:

 oc get co

Query cluster information.

oc adm release info

And that’s it. You now have OpenShift cluster running in your local Ubuntu Linux machine. If you encounter any error let us know through the comments section