DEV Community

Cover image for How to Set Up OpenShift Local (CRC) on Ubuntu: A Developer's Guide
Khuram Murad
Khuram Murad

Posted on

How to Set Up OpenShift Local (CRC) on Ubuntu: A Developer's Guide

Red Hat's CodeReady Containers (CRC) provides developers with a lightweight, local OpenShift 4 cluster perfect for development and testing. In this guide, I'll walk you through setting up CRC on Ubuntu, sharing some tips and tricks I learned along the way.

System Requirements

Before we begin, ensure your system meets these minimum requirements:

  • Ubuntu Linux (20.04 or newer)
  • 9GB RAM (16GB recommended for better performance)
  • 4 CPU cores
  • 35GB free disk space
  • Administrative (sudo) access
  • Hardware virtualization support (VT-x or AMD-v)

Step 1: Prepare Your System

First, let's ensure your system has the necessary virtualization support. Open a terminal and run:

# Update package list
sudo apt update

# Install KVM and libvirt
sudo apt install qemu-kvm libvirt-daemon libvirt-daemon-system

# Verify KVM installation
kvm-ok
Enter fullscreen mode Exit fullscreen mode

The kvm-ok command should indicate that virtualization is supported and enabled in your BIOS.

Step 2: Install Required Dependencies

CRC needs certain packages to function properly:

# Install QEMU and virtiofsd
sudo apt install qemu-system virtiofsd

# Add your user to the libvirt group
sudo usermod -aG libvirt $USER
newgrp libvirt
Enter fullscreen mode Exit fullscreen mode

Step 3: Download and Install CRC

  1. Download the latest CRC from Red Hat's Developer portal
  2. Extract and install the binary:
# Extract the archive
tar -xvf crc-linux-amd64.tar.xz

# Move binary to your PATH
sudo mv crc-linux-*/crc /usr/local/bin/

# Make it executable
sudo chmod +x /usr/local/bin/crc
Enter fullscreen mode Exit fullscreen mode

Step 4: Setup and Start CRC

Now we're ready to set up and start CRC:

# Run initial setup
crc setup

# Start the cluster
crc start
Enter fullscreen mode Exit fullscreen mode

The setup process will:

  • Configure network settings
  • Set up the libvirt network
  • Configure the system for virtualization
  • Download the OpenShift bundle if needed

Common Issues and Solutions

1. Virtualization Error

If you see errors about virtualization, ensure it's enabled in your BIOS/UEFI settings.

2. Memory Issues

Default memory allocation might not be enough. Adjust it with:

crc config set memory 16384  # Sets memory to 16GB
Enter fullscreen mode Exit fullscreen mode

3. Network Configuration

If you encounter network issues, try:

crc cleanup
crc setup
crc start
Enter fullscreen mode Exit fullscreen mode

Useful Commands

Here are some helpful commands for managing your CRC installation:

# Stop the cluster
crc stop

# Delete the cluster
crc delete

# View cluster status
crc status

# Get console URL and credentials
crc console --credentials

# Clean up CRC installation
crc cleanup
Enter fullscreen mode Exit fullscreen mode

Working with the Cluster

Once your cluster is running, you can:

  1. Access the OpenShift web console using the URL provided
  2. Use oc commands to interact with the cluster
  3. Deploy applications using oc new-app
  4. Use the integrated container registry

Tips for Better Performance

  1. Allocate more resources if available:
crc config set memory 16384
crc config set cpus 6
Enter fullscreen mode Exit fullscreen mode
  1. Enable nested virtualization if available:
crc config set enable-nested-virtualization true
Enter fullscreen mode Exit fullscreen mode
  1. Use the built-in monitoring tools to keep track of resource usage:
crc console --credentials
# Then access the monitoring dashboard in the OpenShift console
Enter fullscreen mode Exit fullscreen mode

Conclusion

CRC provides a fantastic way to run OpenShift locally for development and testing. While the initial setup might seem daunting, following these steps should get you up and running smoothly.

Remember that CRC is designed for development and testing - it's not meant for production workloads. However, it provides most OpenShift features you need for development, making it an invaluable tool in your development workflow.

Have you set up CRC on your system? What challenges did you face? Share your experiences in the comments below!


Note: The commands and steps in this guide were tested on Ubuntu 22.04 LTS, but should work on other recent Ubuntu versions as well.

Top comments (0)