Get started!
CRC is local OpenShift, focusing on making it easy to learn and develop for OpenShift. This guide will help you get started with CodeReady Containers (CRC) in OpenShift. CRC provides a way to run OpenShift locally for development and testing purposes.
Getting CRC
In order to download and install CRC, please refer to the Installation Guide.
-
Ensure you have the minimum hardware and software requirements for CRC.
-
Download the latest CRC release from the official website.
-
Install the CRC binary and add it to your system’s PATH.
Creating OpenShift cluster
We will be creating a single-node cluster for Red Hat OpenShift Container Platform.
Once you’ve downloaded and installed CRC on your machine, you’re ready to use CRC by creating a cluster. OpenShift is the default cluster type that would be created when no explicit configuration is provided.
Set up environment for your cluster
Before starting cluster, you need to prepare your machine for creating a Virtual Machine. OpenShift cluster would be started
inside that Virtual Machine. In order to do that use crc setup
command.
Open a terminal with a user account with administrator access (but not logged in as root user) and run:
$ crc setup
Start your cluster
Once you’ve set up environment for your OpenShift cluster, you can go ahead and start it.
When you’d start the cluster, you would be asked for pull secret. You need to create a Red Hat account and download this file from the Pull Secret section of the CRC page on the Red Hat Hybrid Cloud Console. |
$ crc start
Log into your cluster
Once you’ve created the cluster, and it’s up and running, you need to log in into your OpenShift cluster. In order to do that, use OpenShift CLI (oc
).
If you already have OpenShift CLI (oc
), you can start using it. If not, you can use Run the crc oc-env
command to print the command needed to add the cached oc
executable to your $PATH
.
$ crc oc-env
Get the OpenShift CLI (oc
) login command using crc console
to login as regular user or admin.
Copy login command from this CRC command output and paste it into your terminal:
$ crc console --credentials
Deploy a sample application to your OpenShift cluster
We will be deploying a simple Java application using a tool called Eclipse JKube OpenShift Maven Plugin.
In order to follow these steps, you would need to have these installed:
Once you’ve installed these dependencies, you can deploy any java application to OpenShift cluster.
Clone Eclipse JKube repository and go to one of the quickstarts:
$ git clone https://github.com/eclipse-jkube/jkube.git $ cd jkube/quickstarts/maven/quarkus
Run JKube OpenShift Maven Plugin goal to build and deploy application to OpenShift cluster:
$ mvn package oc:build oc:resource oc:apply
Wait till application pod comes in ready state and access the application via route:
$ oc get routes $ curl http://quarkus-default.apps-crc.testing
Creating OKD cluster
We will be creating a single-node cluster for OpenShift Kubernetes Distribution.
Once you’ve downloaded and installed CRC on your machine, you’re ready to use CRC by creating a cluster. OKD is not the default cluster type that would be created when no explicit configuration is provided.
In order to instruct CRC to create a OKD cluster, we need to update CRC configuration:
$ crc config set preset okd
Set up environment for your cluster
Before starting cluster, you need to prepare your machine for creating a Virtual Machine. OKD cluster would be started
inside that Virtual Machine. In order to do that use crc setup
command.
Open a terminal with a user account with administrator access (but not logged in as root user) and run:
$ crc setup
Start your cluster
Once you’ve set up environment for your OKD cluster, you can go ahead and start it.
$ crc start
Log into your OKD cluster
Once you’ve created the cluster, and it’s up and running, you need to log in into your OKD cluster. In order to do that, use OKD CLI (oc
).
If you already have OpenShift CLI (oc
), you can start using it. If not, you can use Run the crc oc-env
command to print the command needed to add the cached oc
executable to your $PATH
.
$ crc oc-env
Get the OpenShift CLI (oc
) login command using crc console
to login as regular user or admin.
Copy login command from this CRC command output and paste it into your terminal:
$ crc console --credentials
Deploy a sample application to your OKD cluster
We will be deploying a simple Java application using a tool called Eclipse JKube OpenShift Maven Plugin.
In order to follow these steps, you would need to have these installed:
Once you’ve installed these dependencies, you can deploy any java application to OKD cluster.
Clone Eclipse JKube repository and go to one of the quickstarts:
$ git clone https://github.com/eclipse-jkube/jkube.git $ cd jkube/quickstarts/maven/quarkus
Run JKube OpenShift Maven Plugin goal to build and deploy application to OKD cluster:
$ mvn package oc:build oc:resource oc:apply
Wait till application pod comes in ready state and access the application via route:
$ oc get routes $ curl http://quarkus-default.apps-crc.testing
Creating MicroShift cluster
We will be creating a single-node cluster for MicroShift.
Once you’ve downloaded and installed CRC on your machine, you’re ready to use CRC by creating a cluster. MicroShift is not the default cluster type that would be created when no explicit configuration is provided.
In order to instruct CRC to create a MicroShift cluster, we need to update CRC configuration:
$ crc config set preset microshift
Set up environment for your cluster
Before starting cluster, you need to prepare your machine for creating a Virtual Machine. MicroShift cluster would be started
inside that Virtual Machine. In order to do that use crc setup
command.
Open a terminal with a user account with administrator access (but not logged in as root user) and run:
$ crc setup
Start your cluster
Once you’ve set up environment for your MicroShift cluster, you can go ahead and start it.
$ crc start
Deploy a sample application to your MicroShift cluster
Create a sample deployment and expose it on port 8080:
$ oc create deployment hello-crc --image=registry.access.redhat.com/ubi8/httpd-24 $ oc expose deployment hello-crc --type=NodePort --port=8080 $ oc expose svc/hello-crc
Wait for application pod to become ready and access application via route:
$ oc get routes $ curl http://hello-crc-default.apps.crc.testing