CodeReady Containers
What is CRC?
CodeReady Containers (CRC) is a minimal, preconfigured OpenShift cluster that is designed to run on your local workstation as a development environment for OpenShift. For more information, see CodeReady Containers.
Similar to Minikube in concept, CRC provides a cloud like environment locally to create and deploy an OpenShift cluster for development and testing purposes.
This page covers some common CRC operations, including deploying Merative Social Program Management (SPM) to the CRC environment. You will use the Helm Charts produced in Preparing Helm Charts.
For a full getting started guide for CRC, see Getting Started Guide CodeReady Containers
Minimum System requirements
CodeReady Containers system requirements can be found here: CRC Minimum system requirements.
Installing CRC
Create an account at RedHat Cloud.
Create a
$CRC_HOME
folder (e.g.~/crc_home
) to use for the purposes of the installation.Download the installation archive from latest release to
$CRC_HOME
and extract the archive:tar -xvf crc-*-amd64.tar.xzOn the same page, download your pull secret to
$CRC_HOME
.Copy the
crc
binary to/usr/local/bin/
sudo cp $CRC_HOME/crc-*-amd64/crc /usr/local/bin/
Whichever option you choose, you should now have crc
in your executable path. Verify by running the following command:
crc version
The output should be similar to the following:
CodeReady Containers version: 1.23.1+be17b141OpenShift version: 4.7.0 (embedded in executable)
Setting up CRC
The first step is to configure the prerequisites for the OpenShift cluster, including taking control of your hosts and resolver files to provide access to the CRC cluster.
To do this run the following command, providing the workstation administrator password as required.
This procedure also creates the ~/.crc
directory if it does not already exist.
crc setup
Now that the basic configuration is complete, you need to edit the configuration to change the memory limit and add the path to the pull secret file downloaded previously.
To change the memory limit, set the CPUs, and add the path to the pull secret file downloaded previously. Run the following commands:
crc config set memory <number-in-MiB>crc config set cpus <whole-number>crc config set pull-secret-file $CRC_HOME/pull-secret.txt
You can always check the configured options of crc
, run the following command:
crc config view
After setup is complete, start the cluster, run the following command:
crc start
This outputs something similar to the following:
INFO Checking if running as non-rootINFO Checking minimum RAM requirementsINFO Checking if Virtualization is enabled......Started the OpenShift cluster.The server is accessible via web console at:https://console-openshift-console.apps-crc.testing
Note the kubeadmin
and developer
credentials for later use.
Next, set up the OpenShift Client oc
, which is used to administer the CRC cluster:
eval $(crc oc-env)
If required, you can stop the cluster:
crc stop
Or delete the cluster:
crc delete
Creating a CRC project
Create a project for the SPM deployment, again use an environment variable for your convenience when following the guide.
Create the environment variable, you can set to value to anything you like, but it should consist of lower case alphanumeric characters or -
, and must start and end with an alphanumeric character (e.g. my-name
, or 123-abc
):
export PROJECT="ocp"
Log in as kubeadmin:
oc login -u kubeadmin -p $KUBEADMN_PSW https://api.crc.testing:6443
Create the project:
oc new-project $PROJECT
Configuring the Image Registry
CodeReady Containers comes with an internal image registry where you can store the application’s Docker images.
The registry is accessed using different URLs, depending on the use - pods use an internal registry service name, and a developer would use the public route to publish the images.
The registry URLs can be retrieved using the oc registry info
command, with either a --public
or --internal
flag.
- Public URL:
default-route-openshift-image-registry.apps-crc.testing
- Use this when tagging and publishing images.
- Internal URL:
image-registry.openshift-image-registry.svc:5000
- Use this when deploying using Helm.
The public URL uses a certificate signed by the OpenShift internal CA, which Docker does not trust by default.
Docker loads all *.crt
files under /etc/docker/certs.d/<registryHost[:port]>
directories and uses them for verifying any self-signed certificates.
More information can be found in the Docker Documentation Use self-signed certificates.
Enable Docker trust certificate:
CERT_PATH="/etc/docker/certs.d/$(oc registry info --public)"sudo mkdir -p $CERT_PATHoc extract secret/router-ca -n openshift-ingress-operator --keys=tls.crt --confirmsudo cp tls.crt $CERT_PATH
Log in to the OpenShift registry:
docker login -u kubeadmin -p $(oc whoami -t) $(oc registry info --public)
Hostname configuration for CRC
This runbook uses a generic hostname of spm-ocp.apps-crc.testing
as an example in commands and the configuration files.
You should add the CRC IP address to the hosts
file by using the generic hostname, or else modify the usage of spm-ocp.apps-crc.testing
in this runbook to reflect your local hostname.
echo -e "$(crc ip)\tspm-ocp.apps-crc.testing" | sudo tee -a /etc/hosts
Where crc ip
is the command that returns the CRC VM’s IP address that is accessible from your workstation.