Chapter 3. Using CodeReady Containers
3.1. Setting up CodeReady Containers
The crc setup
command performs operations to set up the environment of your host machine for the CodeReady Containers virtual machine.
This procedure will create the ~/.crc
directory if it does not already exist.
Prerequisites
-
Your user account must have permission to use the
sudo
command.
-
The
crc
binary should not be run asroot
(or Administrator). Thecrc
binary should always be run with your user account. - If you are setting up a new version, capture any changes made to the instance before setting up a new CodeReady Containers release.
Procedure
Set up your host machine for CodeReady Containers:
$ crc setup
3.2. Starting the virtual machine
The crc start
command starts the CodeReady Containers virtual machine and OpenShift cluster.
Prerequisites
-
The host machine has been set up using the
crc setup
command. For more information, see Section 3.1, “Setting up CodeReady Containers”. A valid OpenShift user pull secret. The pull secret can be copied or downloaded from the Pull Secret section of the Install on Laptop: Red Hat CodeReady Containers page on cloud.redhat.com.
NoteA Red Hat account is required in order to access the user pull secret.
Procedure
Start the CodeReady Containers virtual machine:
For native hypervisors:
$ crc start
- When prompted, supply your user pull secret.
- The cluster takes a minimum of four minutes to start the necessary containers and operators before serving a request.
-
If errors are encountered during
crc start
, check the Chapter 6, Troubleshooting Red Hat CodeReady Containers section for potential solutions.
3.3. Accessing the OpenShift cluster
The OpenShift cluster running in the CodeReady Containers virtual machine can be accessed via the OpenShift web console or the OpenShift client binary (oc
).
3.3.1. Accessing the OpenShift web console
Prerequisites
- A running CodeReady Containers virtual machine. For more information, see Section 3.2, “Starting the virtual machine”.
Procedure
To access the OpenShift web console, follow these steps:
-
Run
crc console
. This will open your web browser and direct it to the web console. Log in to the OpenShift web console as the
developer
user with the password printed in the output of thecrc start
command.Note-
You can also view the password for the
developer
user by runningcrc console --credentials
. -
The cluster can initially be accessed through either the
kubeadmin
ordeveloper
user. For creating projects or OpenShift applications, and for application deployment, thedeveloper
user should be used. Thekubeadmin
user should only be used for administrative tasks such as creating new users, setting roles, and so on.
-
You can also view the password for the
See Chapter 6, Troubleshooting Red Hat CodeReady Containers if you cannot access the CodeReady Containers OpenShift cluster.
Additional resources
- The OpenShift documentation covers the creation of projects and applications.
3.3.2. Accessing the OpenShift cluster with oc
Prerequisites
- A running CodeReady Containers virtual machine. For more information, see Section 3.2, “Starting the virtual machine”.
Procedure
To access the OpenShift cluster via the oc
command, follow these steps:
Run the
crc oc-env
command to print the command needed to add the cachedoc
binary to yourPATH
:$ crc oc-env
- Run the printed command.
Log in as the
developer
user:$ oc login -u developer https://api.crc.testing:6443
NoteThe password for the
developer
user was printed in the output of thecrc start
command. You can also view it by running thecrc console --credentials
command.You can now use
oc
to interact with your OpenShift cluster. For example, to verify that the OpenShift cluster operators are available:$ oc get co
Note-
The
machine-config
cluster operator is expected to reportFalse
availability. -
The
monitoring
cluster operator is expected to reportUnknown
availability.
-
The
See Chapter 6, Troubleshooting Red Hat CodeReady Containers if you cannot access the CodeReady Containers OpenShift cluster.
Additional resources
- The OpenShift documentation covers the creation of projects and applications.
-
OpenShift Do (
odo
) can also be used to create OpenShift projects and applications from the command line.
3.4. Stopping the virtual machine
The crc stop
command stops the running CodeReady Containers virtual machine and OpenShift cluster. The stopping process will take a few minutes while the cluster shuts down.
Procedure
Stop the CodeReady Containers virtual machine and OpenShift cluster:
$ crc stop
3.5. Deleting the virtual machine
The crc delete
command deletes an existing CodeReady Containers virtual machine.
Procedure
Delete the CodeReady Containers virtual machine:
$ crc delete
WarningThe
crc delete
command will result in the loss of data stored in the CodeReady Containers virtual machine. Save any desired instance information before running this command.