Get started with OpenShift

Make the Shift

On Your Marks

Finally, you're ready to run OKD and dig into OpenShift. You can ask Minishift to weave its magic by running the following super-simple command:

$ minishift start

You'll see that an ISO is downloaded, and a number of KVM-related tests are being performed. Keep a close eye on the startup operations, because you'll spot Docker images being pulled down from Docker Hub [10], too.

Depending on the capabilities of your hardware, you might need to be a bit patient and wait for Minishift to complete. The final stage (Starting OpenShift cluster… ) takes my laptop a few minutes to complete. You should eventually be welcomed with a URL that correlates with your shiny, new OpenShift cluster. It will consist of an IP address and TCP port 8443.

If all goes well, you'll be told that you're logged in as the "developer" user, and you'll be instructed how to log in as an administrator with the command:

$ ## oc login -u system:admin

(If you wanted to run it, you'd eliminate the two comment hashes at the start. The line is commented here so that you stick to using the developer user in the tasks that follow.)

Incidentally, if you want to stop Minishift dead in its tracks, you can use the simple command:

$ ## minishift stop

However, leave it running for now. (Again, the line is commented so you don't accidentally stop the cluster at this stage.)

Gooey

Next, you'll enter the URL you were offered – the one showing TCP port 8443 – in a browser. In my case, the URL is https://192.168.42.78:8443/console . I'll accept the warning in my browser that this is an unsafe site, so I can to continue, and click Advanced and then Proceed . To log in, I'll use developer for both the login and password. Figure 3 shows a very welcome dashboard, which is brimming with options.

Figure 3: Just a few of the treasures inside the OKD console's catalog.

I'll leave you to explore and plunder some of the treats in store with OKD and focus on getting an application set up to get you started on your OpenShift journey.

Project X

If you look on the right-hand side of Figure 3, you can see My Project , which has been automatically built for your user developer . Click that link and, in Figure 4, you can see the most common dashboard you would use to operate an application in OpenShift, courtesy of OKD in this instance. For those of you familiar with Kubernetes, note that OpenShift "projects" are "namespaces" in Kubernetes. Projects are effectively used in some use cases to split up customers or departments logically.

Figure 4: Dashboard to configure and operate your OKD project and application.

I'll move away from the GUI for now and deploy a Node.js application from the command line. Although this can be achieved from the GUI, I'll demonstrate how to get started with the command-line interface.

Rather than using the kubectl command, as you would with Kubernetes, the base command for OpenShift is oc. To access the oc command, you'll need to set up your shell to connect to your virtual machine. A clever minishift command helps you out:

$ minishift oc-env
export PATH="/root/.minishift/cache/oc/v3.11.0/linux:$PATH"
# Run this command to configure your shell:
# eval $(minishift oc-env)

This command has run an export command and output two bits of information prepended by comments. If you do as you're told, you run the following command:

$ eval $(minishift oc-env)

Next, you should test that this step worked as you hoped and check the output:

$ oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://192.168.42.78:8443
kubernetes v1.11.0+d4cacc0

That's good news. To continue, create a Node.js application by logging in as the developer user on the command line as follows:

$ oc login -u developer

On a freshly built local machine, you might need to install Git before proceeding:

$ apt install git

Now you can create a new application called nodejs-ex, and you'll use the new-app command in OpenShift:

$ oc new-app https://github.com/sclorg/nodejs-ex -l name=myapp

Run the command

$ oc status

to check the status of the application. The output is shown in Listing 1. Try that command a few times to see what OKD is doing behind the scenes as the application comes up.

Listing 1

oc status

$ oc status
In project My Project (myproject) on server https://192.168.42.78:8443
http://nodejs-ex-myproject.192.168.42.78.nip.io to pod port 8080-tcp (svc/nodejs-ex)
  dc/nodejs-ex deploys istag/nodejs-ex:latest <-
    bc/nodejs-ex source builds https://github.com/sclorg/nodejs-ex on openshift/nodejs:10
    deployment #1 deployed 1 hour ago - 1 pods
2 infos identified, use 'oc status --suggest' to see details.

You can also track the logs of that application with the command:

$ oc logs -f bc/nodejs-ex

which has functionality similar to the tail -f command. Next, you can open a port and expose the networking:

$ oc expose svc/nodejs-ex
route.route.openshift.io/nodejs-ex exposed

There's no doubt that OKD has been busy behind the scenes. If you run the command

$ minishift openshift service nodejs-ex

to check on which URL the new service is being presented, you'll see the output in Figure 5.

Figure 5: Check the URL for the nodejs-ex application.

Now pop that URL into a browser: excellent news. As you can see, Figure 6 denotes success!

Figure 6: Node.js in all its glory, as served from OKD.

One final test will make sure you can configure your project inside the dashboards of the GUI. In my case, the URL is https://192.168.42.78:8443/console/project/myproject/overview . Simply change the IP address to suit your needs. Figure 7 shows the console has updated itself with live data, without the need for a page refresh.

Figure 7: You can see all the options clearly in the console.

To get a feel for how OpenShift can be operated, I attempted a basic test as, shown in Figure 7. To try this for yourself, simply increase the number of pods on the right-hand side to scale up the number of containers that will be available for your application.

After a moment, you'll see a second pod running, which means you can easily accept more traffic. This functionality is pretty clever by anybody's measure, I'm sure you'll agree. For help, see the "Troubleshooting" box.

Troubleshooting

The OKD platform can be difficult to navigate at first, and there's one or two gotchas for the installation of Minishift, too. Fret not, however, because someone has surely had the same issues, and you will find a solution online somewhere. Should you get stuck while installing OKD, have a look at the instructions on the website [11].

OpenShift and OKD have several online resources for instructions on their use, and they are also worth checking out. For example, you'll find a wealth of information on the OKD docs website [12].

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus