Skip to content

OpenShift 4 CodeReady Containers

Endi S. Dewata edited this page Oct 18, 2023 · 6 revisions

Prerequisites

  • RAM: 16 GB

  • Disk: 50 GB

Installing OpenShift Cluster

Download the CodeReady Containers:

$ wget https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz
$ tar xvf crc-linux-amd64.tar.xz
$ cd crc-linux-2.27.0-amd64
$ ./crc setup

Starting OpenShift Cluster

Start the CodeReady Containers with the following command:

$ ./crc start

When asked, provide the Pull Secret from the Download page. Once it’s done, it will display the following information:

The server is accessible via web console at:
  https://console-openshift-console.apps-crc.testing

Log in as administrator:
  Username: kubeadmin
  Password: <password>

Log in as user:
  Username: developer
  Password: developer

Use the 'oc' command line interface:
  $ eval $(crc oc-env)
  $ oc login -u developer https://api.crc.testing:6443

If needed, the credentials can be displayed with the following command:

$ ./crc console --credentials
To login as a regular user, run 'oc login -u developer -p developer https://api.crc.testing:6443'.
To login as an admin, run 'oc login -u kubeadmin -p <password> https://api.crc.testing:6443'

Installing OpenShift Clients

$ dnf install origin-clients

Configuring Client

Configure /etc/hosts on the client as follows:

<Server IP> api.crc.testing canary-openshift-ingress-canary.apps-crc.testing console-openshift-console.apps-crc.testing default-route-openshift-image-registry.apps-crc.testing downloads-openshift-console.apps-crc.testing oauth-openshift.apps-crc.testing

Accessing OpenShift Console

Create /etc/systemd/system/openshift-console.service on the server with the following content:

[Unit]
Description=OpenShift Console

[Service]
ExecStart=/usr/bin/socat TCP-LISTEN:443,fork TCP:<CRC IP>:443

[Install]
WantedBy=multi-user.target

Then start the service as follows:

$ sudo systemctl start openshift-console

The Console can be accessed at https://console-openshift-console.apps-crc.testing.

Accessing OpenShift API

Create /etc/systemd/system/openshift-api.service on the server with the following content:

[Unit]
Description=OpenShift API

[Service]
ExecStart=/usr/bin/socat TCP-LISTEN:6443,fork TCP:<CRC IP>:6443

[Install]
WantedBy=multi-user.target

Then start the service as follows:

$ sudo systemctl start openshift-api

The API can be accessed at https://api.crc.testing:6443.

Authentication

To authenticate as developer:

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

To authenticate as kubeadmin:

$ oc login -u kubeadmin -p <password> https://api.crc.testing:6443

Starting OpenShift Console

To display access credentials:

$ ./crc console --credentials

To start the console:

$ ./crc console

Stopping OpenShift Cluster

$ ./crc stop

Removing OpenShift Cluster

$ ./crc delete

See Also