It's easy to get started with OpenShift whether you're using our app templates or bringing your existing assets. In this quick lab we will deploy an application using an exisiting container image. OpenShift will create an image stream for the image as well as deploy and manage containers based on that image. And we will dig into the details to show how all that works.
Goto the terminal and type the following:
$ oc new-app sonatype/nexus:oss
The output should show something *similar* to below:
--> Found container image 8027e6d (2 months old) from Docker Hub for "sonatype/nexus:oss" Red Hat Universal Base Image 7 ------------------------------ The Universal Base Image is designed and engineered to be the base layer for all of your conta inerized applications, middleware and utilities. This base image is freely redistributable, but Re d Hat only supports Red Hat technologies through subscriptions for Red Hat products. This image is maintained by Red Hat and updated regularly. Tags: base rhel7 * An image stream tag will be created as "nexus:oss" that will track this image * This image will be deployed in deployment config "nexus" * Port 8081/tcp will be load balanced by service "nexus" * Other containers can access this service through the hostname "nexus" * This image declares volumes and will default to use non-persistent, host-local storage. You can add persistent volumes later by running 'oc set volume dc/nexus --add ...' --> Creating resources ... imagestream.image.openshift.io "nexus" created deploymentconfig.apps.openshift.io "nexus" created service "nexus" created --> Success Application is not exposed. You can expose services to the outside world by executing one or m ore of the commands below: 'oc expose svc/nexus' Run 'oc status' to view your app.
Now, let's create a route, so that you can get to the app:
$ oc expose svc/nexus
Switch to "Developer" mode, by clicking on the menu, in the top left corner, where it says "Administrator", and pick "Developer"
Click "Container Image", to add an existing image from the container registry
Select the option for "Image name from external registry" and enter "sonatype/nexus:oss", then click the magnifying glass to the far right to search for the image.
Click on the pop-up menu underneath "Application", and select "Unassigned", to have the application not be in the group with the Butterfly Terminal.
If this menu is not present, it's not a problem.
Enter the values shown, in the image above.
|Create a route to the application||Checked|
Try typing the following to see what is available to 'get':
$ oc get all
Now let's look at what our image stream has in it:
$ oc get is
$ oc describe is/nexus
An image stream can be used to automatically perform an action, such as updating a deployment, when a new image, in our case a new version of the nexus image, is created.
The app is running in a pod, let's look at that:
$ oc describe pods
Let's look at the image stream.
Click on "Developer", in the top left corner, and change it to "Administrator"
Click on "Builds", in the left-side menu, and then "Image Streams"
Now click on the "nexus" image stream
You should see something similar to this:
Change the context menu (the menu, in the top left, that contains "Administrator" and "Developer" back to "Developer", and click on the arrow, at the top right of the "nexus" thumbnail, to open the webapp's route.
You will get a new browser window or tab, containing the following:
Good work - this error is expected; since the nexus console is on /nexus
Go to this URL:
... to get the Nexus console. Of course, we have not provided persistent storage; so, any and all work will be lost.
Let's clean up all this to get ready for the next lab:
$ oc delete all --selector app=nexus
In this lab you've deployed an example container image, pulled from Quay.io, into a pod running in OpenShift. You exposed a route for clients to access that service via thier web browsers. And you learned how to get and describe resources using the command line and the web console. Hopefully, this basic lab also helped to get you familiar with using the CLI and navigating within the web console.