Red Hat OpenShift is the Kubernetes platform from Red Hat, and it's designed for the hybrid cloud. Red Hat OpenShift Container Platform runs on cloud services such as AWS, Azure, and Google Cloud. You can also install and run OpenShift Container Platform on bare metal, but doing so requires a somewhat "demanding" setup.

Is there an alternative available? Yes, there is. This is where Red Hat CodeReady Containers comes into play.

Red Hat CodeReady Containers (CRC) provides a minimal, preconfigured OpenShift 4 cluster on a laptop or desktop machine for development and testing purposes. CRC is delivered as a platform inside of the VM. Now, let's look at how to configure it!

Requirements

The general requirements for CodeReady Containers are:

  • OS: CentOS 7.5-8x/RHEL 7.5-8x/Fedora (latest 2 releases)
  • Download: pull-secret
  • Login: Red Hat account

The physical requirements include:

  • Four virtual CPUs (vCPUs)
  • 9GB of memory (RAM)
  • 35GB of storage space

Setting up

To set up CodeReady Containers, start by creating the crc directory, and then download and extract the crc package:

$ mkdir /home/<user>/crc
$ wget https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz
$ tar -xvf crc-linux-amd64.tar.xz

Next, move the files to the crc directory and remove the downloaded package(s):

$ mv /home/<user>/crc-linux-<version>-amd64/* /home/<user>/crc
$ rm /home/<user>/crc-linux-amd64.tar.xz
$ rm -r /home/<user>/crc-linux-<version>-amd64

Change to the crc directory, make crc executable, and export your PATH like this:

$ cd /home/<user>/crc
$ chmod +x crc
$ export PATH=$PATH:/home/<user>/crc

Set up and start the cluster:

$ crc setup
$ crc start -p /<path-to-the-pull-secret-file>/pull-secret.txt

Set up the OC environment:

$ crc oc-env
$ eval $(crc oc-env)

Log in as the developer user:

$ oc login -u developer -p developer https://api.crc.testing:6443
$ oc logout

And then, log in as the platform’s admin:

$ oc login -u kubeadmin -p password https://api.crc.testing:6443
$ oc logout

Interacting with the cluster

The most common ways of interacting with the cluster include:

  • Start the graphical web console:
$ crc console
  • Display the cluster’s status:
$ crc status
  • Shut down the OpenShift cluster:
$ crc stop
  • Delete or kill the OpenShift cluster:
$ crc delete

Red Hat additionally provides odo (OpenShift Do), a CLI tool for developers, to manage application components on the OpenShift Container Platform. To make use of odo, run the following commands:

$ wget https://mirror.openshift.com/pub/openshift-v4/clients/odo/latest/odo-linux-amd64.tar.gz
$ tar -xvf odo-linux-amd64.tar.gz
$ mv /home/<user>/odo /home/<user>/crc
$ rm odo-linux-amd64.tar.gz
$ cd /home/<user>/crc
$ chmod +x odo

Running an application

After setting up CodeReady Containers on a local machine, how do you run an application on OCP 4? Let’s create the "Wild-West" example project:

$ cd /home/<user>/crc
$ export PATH=$PATH:/home/<user>/crc
$ crc start
$ odo login -u developer -p developer
$ mkdir /home/<user>/wild-west
$ cd /home/<user>/wild-west
$ git clone https://github.com/openshift-evangelists/Wild-West-Backend backend
$ git clone https://github.com/openshift-evangelists/Wild-West-Frontend frontend
$ odo project create wild-west
$ oc import-image openjdk18 --from=registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift --confirm
$ oc annotate istag/openjdk18:latest tags=builder
$ odo catalog list components
$ cd /home/<user>/wild-west/backend
$ mvn package
$ odo create openjdk18 backend --binary target/wildwest-1.0.jar
$ odo config view
$ odo push
$ odo list
$ cd /home/<user>/wild-west/frontend
$ odo create nodejs frontend
$ odo config view
$ odo push
$ odo list
$ odo link backend --port 8080
$ odo url create frontend --port 8080
$ odo push
$ odo list

Once you are finished, you can launch the new application via the web console with:

$ crc console

Wrapping up

Today we learned how to install OpenShift Container Platform on a notebook, create a project, and install an application that runs on top of the platform and can be launched from within the web console. Now it’s your turn to try CRC out on your own projects. The Red Hat CodeReady Containers documentation can certainly help.


关于作者

I am running the latest editions of CentOS, Fedora, and Red Hat Enterprise Linux server and workstation operating systems on physical and virtual machines (VM).

My dedicated capabilities and interests are backup solutions & disaster recovery, hardware drivers, infrastructure deployment, storage management, and virtualization.

UI_Icon-Red_Hat-Close-A-Black-RGB

按频道浏览

automation icon

自动化

有关技术、团队和环境 IT 自动化的最新信息

AI icon

人工智能

平台更新使客户可以在任何地方运行人工智能工作负载

open hybrid cloud icon

开放混合云

了解我们如何利用混合云构建更灵活的未来

security icon

安全防护

有关我们如何跨环境和技术减少风险的最新信息

edge icon

边缘计算

简化边缘运维的平台更新

Infrastructure icon

基础架构

全球领先企业 Linux 平台的最新动态

application development icon

应用领域

我们针对最严峻的应用挑战的解决方案

Virtualization icon

虚拟化

适用于您的本地或跨云工作负载的企业虚拟化的未来