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 has permission to use the sudo command.
Note
  • Do not run the crc binary as root (or Administrator). Always run the crc binary with your user account.
  • If you are setting up a new version, capture any changes made to the virtual machine 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:

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

3.3. Accessing the OpenShift cluster

Access the OpenShift cluster running in the CodeReady Containers virtual machine through the OpenShift web console or 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 and kubeadmin users by running crc console --credentials.
    • You can initially access the cluster through either the kubeadmin or developer user. Use the developer user for creating projects or OpenShift applications and for application deployment. Only use the kubeadmin user for administrative tasks such as creating new users, setting roles, and so on.

See Chapter 7, 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 through 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 crc start command prints the password for the developer user. 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
    • CodeReady Containers disables the machine-config and monitoring Operators by default.

See Chapter 7, 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.
  • You can also use OpenShift Do (odo) 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 results in the loss of data stored in the CodeReady Containers virtual machine. Save any desired information stored in the virtual machine before running this command.