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.
Note
  • The crc binary should not be run as root (or Administrator). The crc 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

  1. 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

Procedure

  • Start the CodeReady Containers virtual machine:

    • For native hypervisors:

      $ crc start
  • When prompted, supply your user pull secret.
Note

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

Procedure

To access the OpenShift web console, follow these steps:

  1. Run crc console. This will open your web browser and direct it to the web console.
  2. Log in to the OpenShift web console as the developer user with the password printed in the output of the crc start command.

    Note
    • You can also view the password for the developer user by running crc console --credentials.
    • The cluster can initially be accessed through either the kubeadmin or developer user. For creating projects or OpenShift applications, and for application deployment, the developer user should be used. The kubeadmin user should only be used for administrative tasks such as creating new users, setting roles, and so on.

See Chapter 6, Troubleshooting Red Hat CodeReady Containers if you cannot access the CodeReady Containers OpenShift cluster.

Additional resources

3.3.2. Accessing the OpenShift cluster with oc

Prerequisites

Procedure

To access the OpenShift cluster via the oc command, follow these steps:

  1. Run the crc oc-env command to print the command needed to add the cached oc binary to your PATH:

    $ crc oc-env
  2. Run the printed command.
  3. Log in as the developer user:

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

    The password for the developer user was printed in the output of the crc start command. You can also view it by running the crc console --credentials command.

  4. 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 report False availability.
    • The monitoring cluster operator is expected to report Unknown availability.

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
    Warning

    The 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.