Using CRC
About presets
CRC presets represent a managed container runtime, and the lower bounds of system resources required by the instance to run it. CRC offers presets for:
openshift
-
OpenShift Container Platform
okd
-
OKD
microshift
-
MicroShift
On Microsoft Windows and macOS, the CRC guided installer prompts you for your desired preset.
On Linux, the OpenShift Container Platform preset is selected by default.
You can change this selection using the crc config
command before running the crc setup
command.
Only one preset can be active at a time.
Setting up CRC
The crc setup
command performs operations to set up the environment of your host machine for the CRC instance.
The crc setup
command creates the ~/.crc directory if it does not already exist.
If you are setting up a new version, capture any changes made to the instance before setting up a new CRC release. |
-
On Linux or macOS, ensure that your user account has permission to use the
sudo
command. On Microsoft Windows, ensure that your user account can elevate to Administrator privileges.
Do not run the |
-
Set up your host machine for CRC:
$ crc setup
Starting the instance
The crc start
command starts the CRC instance and configured container runtime.
-
To avoid networking-related issues, ensure that you are not connected to a VPN and that your network connection is reliable.
-
You have set up CRC.
-
On Microsoft Windows, ensure that your user account can elevate to Administrator privileges.
-
For the OpenShift preset, ensure that you have a valid OpenShift user pull secret. Copy or download the pull secret from the Pull Secret section of the CRC page on the Red Hat Hybrid Cloud Console.
Accessing the user pull secret requires a Red Hat account.
-
Start the CRC instance:
$ crc start
-
For the OpenShift preset, supply your user pull secret when prompted.
The cluster takes a minimum of four minutes to start the necessary containers and Operators before serving a request.
-
If you see errors during
crc start
, see the Troubleshooting CRC section for potential solutions.
Accessing the OpenShift cluster
Access the OpenShift Container Platform cluster running in the CRC instance by using the OpenShift Container Platform web console or OpenShift CLI (oc
).
Accessing the OpenShift web console
Access the OpenShift Container Platform web console by using your web browser.
Access the cluster by using either the kubeadmin
or developer
user.
Use the developer
user for creating projects or OpenShift applications and for application deployment.
Use the kubeadmin
user only for administrative tasks such as creating new users or setting roles.
-
CRC is configured to use the OpenShift preset. See: Changing the selected preset.
-
A running CRC instance. See: Starting the instance.
-
To access the OpenShift Container Platform web console with your default web browser, run the following command:
$ crc console
-
Log in as the
developer
user with the password printed in the output of thecrc start
command. You can also view the password for thedeveloper
andkubeadmin
users by running the following command:$ crc console --credentials
See Troubleshooting CRC if you cannot access the OpenShift Container Platform cluster managed by CRC.
-
The OpenShift Container Platform documentation covers the creation of projects and applications.
Accessing the OpenShift cluster with the OpenShift CLI
Access the OpenShift Container Platform cluster managed by CRC by using the OpenShift CLI (oc
).
-
CRC is configured to use the OpenShift preset. See: Changing the selected preset.
-
A running CRC instance. See: Starting the instance.
-
Run the
crc oc-env
command to print the command needed to add the cachedoc
executable to your$PATH
:$ crc oc-env
-
Run the printed command.
-
Log in as the
developer
user:$ oc login -u developer https://api.crc.testing:6443
The
crc start
command prints the password for thedeveloper
user. You can also view it by running thecrc console --credentials
command. -
You can now use
oc
to interact with your OpenShift Container Platform cluster. For example, to verify that the OpenShift Container Platform cluster Operators are available, log in as thekubeadmin
user and run the following command:$ oc config use-context crc-admin $ oc whoami kubeadmin $ oc get co
CRC disables the Cluster Monitoring Operator by default.
See Troubleshooting CRC if you cannot access the OpenShift Container Platform cluster managed by CRC.
-
The OpenShift Container Platform documentation covers the creation of projects and applications.
Accessing the internal OpenShift registry
The OpenShift Container Platform cluster running in the CRC instance includes an internal container image registry by default. This internal container image registry can be used as a publication target for locally developed container images. To access the internal OpenShift Container Platform registry, follow these steps.
-
CRC is configured to use the OpenShift preset. See: Changing the selected preset.
-
A running CRC instance. See: Starting the instance.
-
A working OpenShift CLI (
oc
) command. See: Accessing the OpenShift cluster with the OpenShift CLI.
-
Check which user is logged in to the cluster:
$ oc whoami
For demonstration purposes, the current user is assumed to be
kubeadmin
. -
Log in to the registry as that user with its token:
$ oc registry login --insecure=true
-
Create a new project:
$ oc new-project demo
-
Mirror an example container image:
$ oc image mirror registry.access.redhat.com/ubi8/ubi:latest=default-route-openshift-image-registry.apps-crc.testing/demo/ubi8:latest --insecure=true --filter-by-os=linux/amd64
-
Get imagestreams and verify that the pushed image is listed:
$ oc get is
-
Enable image lookup in the imagestream:
$ oc set image-lookup ubi8
This setting allows the imagestream to be the source of images without having to provide the full URL to the internal registry.
-
Create a pod using the recently pushed image:
$ oc run demo --image=ubi8 --command -- sleep 600s
Deploying a sample application with odo
You can use odo
to create OpenShift projects and applications from the command line.
This procedure deploys a sample application to the OpenShift Container Platform cluster running in the CRC instance.
-
You have installed
odo
. For more information, see Installingodo
in theodo
documentation. -
CRC is configured to use the OpenShift preset. See: Changing the selected preset.
-
The CRC instance is running. See: Starting the instance.
-
Log in to the running OpenShift Container Platform cluster managed by CRC as the
developer
user:$ odo login -u developer -p developer
-
Create a project for your application:
$ odo project create sample-app
-
Create a directory for your components:
$ mkdir sample-app $ cd sample-app
-
Clone an example Node.js application:
$ git clone https://github.com/openshift/nodejs-ex $ cd nodejs-ex
-
Add a
nodejs
component to the application:$ odo create nodejs
-
Create a URL and add an entry to the local configuration file:
$ odo url create --port 8080
-
Push the changes:
$ odo push
Your component is now deployed to the cluster with an accessible URL.
-
List the URLs and check the desired URL for the component:
$ odo url list
-
View the deployed application using the generated URL.
-
For more information about using
odo
, see theodo
documentation.
Stopping the instance
The crc stop
command stops the running CRC instance and container runtime.
The stopping process takes a few minutes while the cluster shuts down.
-
Stop the CRC instance and container runtime:
$ crc stop