How to Set Up Container Development on Your Local Machine in Minutes

DZone 's Guide to

How to Set Up Container Development on Your Local Machine in Minutes

Check out how you can quickly set up container deployment with Code Ready Containers.

· Cloud Zone ·
Free Resource

Code Ready Containers

It's been a while since I've talked about running OpenShift Container Platform on your local machine.

This means a container platform at your finger tips, one you can use to experience the joys of cloud-native development and automated rolling deployments. Since I started pulling together ways to easily experience this with OpenShift Container Platform (back with version 3.3, believe it or not) we've come a long way.

You may also enjoy:  OpenShift Quick Start

For some time now I've been waiting for the local installation that stopped being supported with OpenShift Container Platform 3.9 to reappear in version 4.x. Well, now it's finally here with the last release of OpenShift Container Platform 4.2, in the form of Code Ready Containers.

The idea was to make this as streamlined of an experience as possible by using the same OpenShift Container Platform Easy Local Install project. Let's take a look at what this looks like.

The first focus was to have this work for Unix-based operating systems using a single installation script. The secondary wish is to provide a Windows-based installation script.

Linux or Mac Installation

This installation requires the following (all freely available):

  1. 1. HyperKit for OSX, Hyper-V for Windows, or Libvirt for Linux
    2. Code Ready Containers (OCP 4.2)
    3. OpenShift Client (oc) v4.2.0 
  2. 1. HyperKit for OSX, Hyper-V for Windows, or Libvirt for Linux
    2. Code Ready Containers (OCP 4.2)
    3. OpenShift Client (oc) v4.2.0 
  3. 1. HyperKit for OSX, Hyper-V for Windows, or Libvirt for Linux
    2. Code Ready Containers (OCP 4.2)
    3. OpenShift Client (oc) v4.2.0 

First, you need to ensure your virtualization tooling is installed for your platform; just search online for how to do that or use your specific platform. Second, you need to download the Code Ready Containers. Finally, you need the OpenShift client.

Normally you'd expect to have to track these last two down but we've made this all easy by just including checks during the installation. If you have something installed, it checks the version. If it's good then it moves on with the next steps. If anything is missing or you have the wrong version, the installation stops and notifies you where to find that component for your platform (including URL).

Let's get started by downloading the OpenShift Container Platform Easy Local Install Project and unzipping in some directory. This gives you a file called ocp-install-demo-master.zip,just unzip and run the init.sh as follows:

 $ ./init.sh 

Follow the instructions as each of the dependencies is checked and you're provided with pointers to getting the versions you need for your platform.

Note: Each Code Ready Container download is tied to an embedded secret. This secret you need to download (link will be provided) as a file and you'll be asked to point to that secret to start your container platform. This pull-secret has a 30-day lifespan, so once it's expired you'll need to download both a new Code Ready Container AND a new pull-secret.

Once you've got all the dependencies sorted out, the install runs like this:

Code Ready Containers install

Code Ready Containers install

A little ASCII art and then it's checking for my platform's virtualization (Hyperkit), looking for the OpenShift client version 4.2 (oc client), then running a setup (crc setup).

Configuring pull-secret-file

Configuring pull-secret-file

The next steps are providing the pull-secret-file. You can set this in the variables at the top of the installation script. Now the moment of truth: the Code Ready Containers cluster starts, which takes some time depending on your network (crc start). With a good network it's about a five-minute wait.

Code Ready Container

Code Ready Container

This is the logging you'll see as the OpenShift cluster starts on your local machine. The warning is normal, just some of the features have been trimmed to speed up deployment.

Successful login

Successful login

At the end we'll retrieve the admin password for logging in to the cluster's console, pick up the host URL, test the deployment by logging in with our client (oc login), and finally you're given all the details in a nice box. You have the option to stop, start it again, or delete the OpenShift Container Platform cluster as shown in the dialog.

Next, open the web console using the URL and the login "kubeadmin" with the corresponding password. In our case it's the URL: https://console-openshift-console.apps-crc.testing



Log in with user: kubeadmin

Password in our case: wyozw-5ywAy-5yoap-7rj8q (this is NOT your password)

That opens the main dashboard:

Main Dashboard

Main Dashboard

This concludes the installation of an OpenShift Container Platform on our local machine using Code Ready Containers.

What About Windows?

A sharp observer might have noticed there's a file called init.bat for the Windows platforms to install with. The problem is we've not been able to test this yet on a Windows machine, so I'd love to call out to the readers out there that might have some time to contribute to test this script and help us complete the installation. You'll notice a few TODO's marked in the scripts code, as they are untested areas in the installation. You can raise new issues here and help us complete the Windows-based installation and get your name added to the contributors list. We'd be really thankful!

Stay tuned for more on cloud-native development using other Red Hat technologies on your new OpenShift Container Platform installed locally on your own machine!

Further Reading

Zero to Cloud Operations on OpenShift in Minutes

What's in OpenShift 4?

Kubernetes vs. OpenShift: What Is the Difference?

architect ,cloud ,cloud-native ,cloud-native development ,containers ,developer ,hands-on ,how-to ,openshift container platform ,tutorial

Published at DZone with permission of Eric D. Schabell , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}