IBM Developer Blog

Follow the latest happenings with IBM Developer and stay in the know.

Use Red Hat CodeReady Containers to run OpenShift 4 in a single node configuration


Do you want to learn Red Hat OpenShift 4? Or do you want to have your own instance of OpenShift on your laptop so that you can quickly do some tests?

I use Minishift on my laptop a lot but Minishift is still based on OKD 3.11, which is the open source upstream version of OpenShift 3.11. An update of Minishift to OpenShift 4 has not happened yet.

In the meantime, I found Red Hat CodeReady Containers, which you can use to run OpenShift 4 in a single node configuration on your workstation or laptop. It operates almost exactly like Minishift and minikube.

Get the code

CodeReady Containers runs on Linux, macOS, and Windows, and it only supports the native hypervisors: Kernel-based Virtual Machine (KVM) for Linux, HyperKit for macOS, and Hyper-V for Windows.

Start with the Install OpenShift 4 on a laptop with CodeReady Containers guide. To access this install guide, you need to log in to your Red Hat account or register for a free account. The login page contains a link to create a new account.

The installation guide contains download links for the CodeReady Containers archives for Linux, macOS, and Windows, a link to download the pull secret, which is the most important piece as it is required during installation, and a Get started link that leads to the Getting Started Guide.

The Getting Started Guide also lists the hardware requirements, which are similar to those for minikube and Minishift:

  • 4 virtual CPUs (vCPUs)
  • 9 GB of RAM
  • 35 GB of disk space for the virtual disk

You will also find the required versions of Windows 10 and macOS in the guide.

I am running Red Hat Fedora (Fedora 31 at the moment) on my notebook and I normally use VirtualBox as the hypervisor. But VirtualBox is not supported for CodeReady Containers so I had to install KVM first. The requirements for CodeReady Containers also mention the NetworkManager package as a requirement, but most current Linux distributions will use it anyway. Fedora certainly does. Additional instructions are available for running CodeReady Containers on Ubuntu.

Installation

At the time of writing this blog post, CodeReady Containers is at version 1.12 and includes OpenShift version 4.4.8.

Start by downloading the CodeReady Containers archive for your operating system and download the pull secret to a location you remember. Extracting the CodeReady Containers archive results in an executable crc file, which needs to be placed somewhere on your PATH. This is very similar to the minikube and minishift executable files.

First step is to set up CodeReady Containers as follows:

$ crc setup

This checks the prerequisites, installs some drivers, configures the network, and creates an initial configuration in a .crc directory (on Linux).

You can check the configurable options of crc with the following command:

$ crc config view

I have a notebook with 32 GB of RAM and therefore changed the memory limit to 16 GB. I also added the path to the pull secret file to the CodeReady Containers configuration with these commands:

$ crc config set memory 16384
$ crc config set pull-secret-file path/to/pull-secret.txt

Initialize and start CodeReady Containers with the following command:

$ crc start

This takes awhile (several minutes). In the end, you receive instructions on how to access the cluster as follows:

INFO To access the cluster, first set up your environment by following 'crc oc-env' instructions
INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443'
INFO To login as an admin, run 'oc login -u kubeadmin -p fq66o-KsVBU-cnKBU-xLpqd https://api.crc.testing:6443'
INFO                                              
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console

Note: I didn’t accidentally expose my super secret CodeReady Containers credentials here in this blog post. They are the same for everyone, hardcoded in the CodeReady Containers binary, and change with every new release.

I found that you need to wait a few minutes after the crc start command finished because OpenShift isn’t totally started then. Check the status with the following command:

$ crc status

Output should look like:

CRC VM:          Running
OpenShift:       Running (v4.4.8)
Disk Usage:      12.08GB of 32.72GB (Inside the CRC VM)
Cache Usage:     24.24GB
Cache Directory: /home/uebele/.crc/cache

If your cluster is up, access it with the command line tool, OpenShift CLI (oc), by using the parameters in the completion message. oc is installed together with CodeReady Containers. You enable access to it by using the following command:

eval $(crc oc-env)

Or you can access the OpenShift web console with this command:

$ crc console

Choose to log in with kube:admin if you want to be the administrator of OpenShift. User is kubeadmin and the password is printed in the completion message that I shared earlier in this post. You must accept the self-signed certificates (twice) to be presented with an OpenShift 4 web console.

Screen capture of OpenShift web console

There are some more commands that you probably need:

  • crc stop stops the OpenShift cluster
  • crc delete completely deletes the cluster

I am really impressed with CodeReady Containers. You gain the full OpenShift 4 experience with the new web console and the OperatorHub catalog to get started with Operators.

Expiration

Red Hat releases a new version of CodeReady Containers about once per month and it includes the latest version of OpenShift. With early versions, you had to install each new CodeReady Container version because the OpenShift certificates expired after about 30 days. Starting with CodeReady Containers version 1.2.0, the certificates that are used in OpenShift no longer expire. To be precise, they do expire, but CodeReady Containers renews them at crc start after they expire and you receive a message during launch that a newer version is available.

Test drive CodeReady Containers

My team created a project called Cloud Native Starter with code, scripts, and documentation that demonstrate how to get started with cloud-native applications and microservice-based architectures. There are instructions for running the sample application in four different environments, including instructions for deploying the app on CodeReady Containers with Red Hat OpenShift Service Mesh (which is based on Istio).

Screen capture of a sample web application built within the Cloud Native Starter project

As a next step, I invite you to try CodeReady Containers by using the sample code in the Cloud Native Starter project.