How to run OpenShift 4 on your notebook
Tags: kubernetes, cloud, container, openshift
Published: 2020-03-19 13:34:48

OpenShift is Red Hat's version of Kubernetes, simply put. It includes
tools and features that make it very interesting for developers. But
since it is a commercial product it normally comes with a fee.

You may know Minikube, a tool to run "vanilla" Kubernetes in a virtual
machine on your notebook. You may also know Minishift, which does the same for OKD which is the open source upstream project of OpenShift. Minishift is based on OKD version 3.xx, though. OpenShift version 4 is very different from OpenShift and OKD version 3. There is work underway for a version 4 of OKD but this still seems to take some time.

Last year I found something called  **Red Hat CodeReady Containers** and this allows to run OpenShift 4.3 in a single node configuration on your
workstation. For free! It operates almost exactly like Minishift and Minikube. Actually under the covers it is completely different but that's
another story. 

CodeReady Containers (CRC) runs on Linux, MacOS, and Windows, and it only supports the native hypervisors: KVM for Linux, Hyperkit for MacOS, and HyperV for Windows. 

This is the place where you need to start: [Install on Laptop: Red Hat
CodeReady Containers](https://cloud.redhat.com/openshift/install/crc/installer-provisioned)

You need a Red Hat account to access this page, you can register right
there and it is free. It contains a link to the [Getting Started](https://code-ready.github.io/crc/) guide, the download link for CodeReady Containers (for Windows, MacOS, and Linux) and a link to download the *pull secret* which is required during installation and is therefore the most important piece.

The Getting Started guide lists the hardware requirements, they are similar to those for Minikube and Minishift:

-   4 vCPUs
-   8 GB RAM (IMHO you need at least 16 GB to use CRC)
-   35 GB disk space for the virtual disk

You will also find the required versions of Windows 10 and MacOS there. 

I am running Fedora (F30 at the moment) on my notebook and I normally use VirtualBox as hypervisor. CRC does not support VirtualBox so I had to install KVM first, here are good [instructions](https://computingforgeeks.com/how-to-install-kvm-on-fedora/). The requirements for CRC also mention NetworkManager as required but most Linux distributions will use it, Fedora certainly does. There are additional instructions for Ubuntu/Debian/Mint users for libvirt in the
Getting Started guide and [here](https://github.com/code-ready/crc/issues/549).

Start with downloading the CodeReady Containers archive for your OS and download the pull secrets to a location you remember. Extracting the CodeReady Containers archive results in an executable 'crc' which needs to be placed in your PATH. This is very similar to the 'minikube' and 'minishift' executables.

First step is to setup CodeReady Containers:

 `$ crc setup`

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

You can check the configurable options of'crc' with:

 `$ crc config view`

Since I plan to test OpenShift Service Mesh (= Istio) on CRC I have
changed the memory limit to 16 GB and added the path to the pull secret file:

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

Start CodeReady Containers with:

 `$ crc start`

This will take a while and in the end give you instructions on how to access the cluster. 

```
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 db9Dr-J2csc-8oP78-9sbmf https://api.crc.testing:6443'
INFO
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console
```

I found that you need to wait a few minutes after that because OpenShift
is some times not completely started. Check with:

 `$ crc status`

Output should look like:

```
CRC VM: Running 
OpenShift: Running (v4.3.1) 
Disk Usage: 22.28GB of 32.72GB (Inside the CRC VM) 
Cache Usage: 12.3GB 
Cache Directory: /home/uebele/.crc/cache
```

If your cluster is up, access it using the link in the completion message or use:

 `$ crc console`

User is 'kubeadmin' and the password has been printed in the completion message above. You will need to accept the self-signed certificates and then be presented with an OpenShift 4 Web Console:

![Web Console](https://dev-to-uploads.s3.amazonaws.com/i/cp2o81zrckc47bv5q2c8.png)

There are some more commands that you probably need:

1.  'crc stop' stops the OpenShift cluster
2.  'crc delete' completely deletes the cluster
3.  'eval $(crc oc-env)' correctly sets the environment for the 'oc' CLI

I am really impressed with CodeReady Containers. It gives you the full
OpenShift 4 experience with the new Web Console and even includes the OperatorHub catalog to get started with Operators.

#### Updates

New CRC versions come out about once per month. You don't need to
install them but they offer the latest version of OpenShift at that
time. Updating means to delete the old VM and create a new one. 

A very good place for current information is the CRC Github issues
page [here](https://github.com/code-ready/crc/issues).