Getting Started with OpenShift Local
Virtualization and cloud computing are two popular technologies that driving the industry. Advancement of virtualization allows organizations to diminish power consumptive, consolidating servers, testing and development, dynamic load balancing and recovery from catastrophic events, virtual workstations and enhanced system reliability and safety. On the other hand, cloud computing delivers computing as a service that shared resources, software solutions, and the information is provided for use by computers and other devices using a network. Virtualization is the key technology in the cloud computing industry. It enables cloud computing hardware within a pool of distributed shared resources.
RedHat OpenShift Local (formerly Red Hat CodeReady Containers) is a perfect example of combining Virtualization and cloud computing. It’s the quickest way to get started building OpenShift clusters.
I was looking for quickly setup an OpenShift cluster on RHEL for some random testing purpose, with minimal resource requirements. The OpenShift Local allows bring up an environment in 10–15 minutes. It just needs 4 CPU (vCPU), 9 GB of free memory and 35 GB of storage space. There are many documents that explains the installation process, but I found some little thinks are missing. For example: how to enable sudo access for user, configuration required for accessing OpenShift console etc. In this blog, I am going to walk you through the installation process of OpenShift Local on environment.
About
Red Hat OpenShift Local brings a minimal OpenShift 4.x cluster to your local computer for development and experiment purposes. There is no need of any cloud environment like AWS, GCP, Azure or IBM Cloud for OpenShift Local. No matter what Operating System you are using on you Laptop; macOS, Windows or Linux — you can install it without much effort.
Differences from OpenShift Container Platform
- OpenShift Local cluster is ephemeral and not intended for production use. Use it for development and testing purposes only.
- There is no supported upgrade path to newer version for OpenShift Local. Upgrading the OpenShift version may cause issues that are difficult to reproduce.
- It uses a single node which behaves as both a control plane and worker node.
- Cluster Monitoring Operator is disables by default. This disabled Operator causes the corresponding part of the web console to be non-functional.
- The OpenShift instance runs in a virtual machine. This may cause other differences, particularly with external networking.
- In most cases cluster settings are non-customizable. For example: domain name is pre-set to *.crc.testing.
- Customer is pre-defined with IP address range — 172.x.x.x
- Not possible to install IBM Cloud Pak for Data.
Install OpenShift Local on Red Hat Linux
instruction for install OpenShift on Red Hat Linux.
- Create a RedHat node with 4 Core CPU, 9Gb RAM and 35GB free storage.
- Install necessary libvirt and NetworkManager packages for OpenShift Local as user
root
.
yum install -y libvirt NetworkManager
3. Create a user on your cluster and set the password. You need a non-root user to run OpenShift Local. Following commands create user crcuser
and set password as crcuser
.
adduser crcuser
passwd crcuser
Enable sudo access for user crcuser
.
usermod -aG wheel crcuser
echo -e "crcuser\tALL=(ALL)\tNOPASSWD: ALL" > /etc/sudoers.d/020_sudo_for_me
4. Logout from user root
5. Login as user crcuser
6. Download the latest release of OpenShift Local for your platform and extract it. You need an account on redhat.com.
wget https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xztar xvf crc-linux-amd64.tar.xz
7. Change directory to the extracted location. Directory name may be different in your case.
cd crc-linux-2.4.1-amd64
8. Download your RedHat pull secret from https://console.redhat.com/openshift/create/local and save it as “pull-secret”.
9. Set up your host machine. You may need to set the PATH, if crc command not found.
crc setup
10. Start the virtual machine. Make sure pull-secret
file is in your current directory.
crc start -p pull-secret -m 12244
11. Add oc executable to the PATH
crc oc-env
export PATH=$HOME/.crc/bin/oc:$PATH
12. Use any oc
commands to verify you have CLI access.
13. Install haproxy
sudo yum install -y haproxy
sudo systemctl enable haproxy
sudo systemctl start haproxy
14. Create haproxy configuration file
export CRC_IP=$(crc ip)
sudo tee /etc/haproxy/haproxy.cfg &>/dev/null <<EOF
global
log /dev/log local0defaults
balance roundrobin
log global
maxconn 100
mode tcp
timeout connect 5s
timeout client 500s
timeout server 500slisten app
bind 0.0.0.0:80
server crcvm $CRC_IP:80 checklisten apps_ssl
bind 0.0.0.0:443
server crcvm $CRC_IP:443 checklisten api
bind 0.0.0.0:6443
server crcvm $CRC_IP:6443 check
EOF
15. Install haproxy
sudo systemctl restart haproxy
16. Add an entry to local machine (from where you accessing web browser) /etc/host file
xx.xx.xx.xx api.crc.testing console-openshift-console.apps-crc.testing default-route-openshift-image-registry.apps-crc.testing oauth-openshift.apps-crc.testing
17. Access OpenShift console from local machine browser
https://console-openshift-console.apps-crc.testing
Troubleshooting
The most of issues you can resolved by stopping OpenShift Local virtual machine, deleting the virtual machine, and starting a new instance of the virtual machine.
1. Stop CRC instance: crc stop
2. Delete CRC instance (remove all data): crc delet
3. Clean up changes (revert configuration changes): crc cleanup
4. Setup host machine: crc setup
5. Start CRC instance: crc start -p pull-secret -m 12244
The ~/.crc/crc.log
log file contains detailed debugging and troubleshooting information which can help diagnose the problem.
In this case I installed OpenShift Local instance on RHEL but if needed you can install it on Windows 10, macOS and different flavor of Linux i.e., CentOS, Ubuntu etc. You can install it on a standalone node or as simple as on a laptop.