Introduction
If you want hands-on experience with OpenShift on your local machine, CodeReady Containers (CRC) provides an excellent solution. CRC allows you to run a single-node OpenShift cluster locally, which is perfect for development and testing. In this guide, we will walk you through the steps of installing CRC on your system.
What are CodeReady Containers?
CodeReady Containers (CRC) is a tool provided by Red Hat that allows developers to create a local OpenShift environment. It simulates an OpenShift cluster with one node suitable for development purposes and testing containerized applications.
System Requirements
Before diving into the installation, ensure your system meets the following minimum requirements:
- Operating System: CRC supports macOS, Linux, and Windows.
- CPU: At least 4 vCPUs.
- Memory: Minimum of 9 GB RAM (recommended 16 GB).
- Disk Space: At least 35 GB of available disk space.
Additionally, Hypervisor support is required.
- macOS: HyperKit
- Linux: libvirt
- Windows: Hyper-V or VirtualBox
Install the necessary dependencies.
Red Hat OpenShift Local requires the libvirt and NetworkManager packages to run on Linux.
sudo apt install qemu-kvm libvirt-daemon libvirt-daemon-system network-manager
Download the CRC Binary
Visit the official CodeReady link to get your operating system’s latest version of CRC. Make sure you’re logged in with a Red Hat account. Once downloaded, follow the instructions for your OS:
- Assuming the archive is in the ~/Downloads directory, follow these steps:
- Extract the contents of the archive:
cd ~/Downloads
tar xvf crc-linux-amd64.tar.xz
- Create the ~/bin directory if it does not exist and copy the
crc
executable to it:
mkdir -p ~/bin
cp ~/Downloads/crc-linux-*-amd64/crc ~/bin
- Add the ~/bin directory to your
$PATH
export PATH=$PATH:$HOME/bin
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
Set Up CRC
After installation, the next step is to set up CRC for your environment. You will also need to download the pull-secret from Red Hat’s download page.
- Configure CRC: Run the following command in your terminal.
crc setup
This will configure the system, install the necessary virtual machine, and ensure that your environment is ready for running the OpenShift cluster.
Start the Red Hat OpenShift Local instance:
crc start
This command will start the OpenShift cluster. For the OpenShift preset, supply your user pull secret when prompted, the pull secret is used to authenticate and pull the required container images.
When asked to enter a pull secret you will need to paste it from your account redhat openshift local page(Create an account if needed).
(Optional): Allocate Resources
If your system has more resources (CPU, RAM), you can allocate them during the setup using the following flags:
crc config set cpus 6
crc config set memory 16384
This command will start the OpenShift cluster, using the pull secret to authenticate and pull the required container images.
Accessing the OpenShift cluster
After the Openshift cluster is successfully provisioned, you will be given admin and developer credentials
Access the OpenShift Container Platform cluster running in the Red Hat OpenShift Local instance by using the OpenShift Container Platform web console or OpenShift CLI (oc).
Common Troubleshooting Tips
- Low Memory or CPU: If CRC fails to start, ensure you’ve allocated enough CPU and RAM as CRC requires substantial resources.
- DNS Resolution Issues: If you’re unable to access the OpenShift console, check your DNS settings to ensure proper resolution of the
*.testing
domain. - Outdated Pull Secret: Make sure your pull secret is up to date by re-downloading it from the Red Hat portal.
Conclusion
CodeReady Containers is an excellent tool for developers looking to get familiar with OpenShift on a local machine without needing access to a full-scale OpenShift cluster. It’s easy to set up, and with this guide, you should have a running OpenShift environment in no time.
By experimenting with CRC, you can gain hands-on experience with OpenShift and prepare yourself for production environments.
Happy Coding!