IBM/minishift101 - step 2 - creating an app from source
After creating a project as instructed in the previous lab (Step 1), the next step is to create an OpenShift application in the cluster.
1. Creating an app
There are several ways in which you can create an app in OpenShift:
From source code
From DockerHub images
From OpenShift templates
From the OpenShift UI
1.1 Creating an app from source
With oc new-app
command, you can create an application in OpenShift from some existing source code either locally or with the url to the repository. If a source repository is specified, new-app
will check to see which build strategy to use (Docker or Source).
With the former, a runnable image is created, whereas as the latter, new-app
will try to identify the language by looking at the files in the project's root directory and then use an appropriate builder.
To build from a local Dockerfile:
To build from source:
1.2 Creating an app from a DockerHub image
Similar to Docker, OpenShift is also configured to the public image registry DockerHub. If you specify an image that exists in DockerHub, the new-app
command will create a runnable image directly from this image.
For example, if you wanted to create an app from the official nginx image, you would run:
You are not limited to the DockerHub registry, however - as with Docker, you are able to specify images that are stored in private registries too:
1.3 Creating an app from an OpenShift template
OpenShift templates are basically starter applications that have been configured ready for OpenShift. These cover frequently used applications deployed in containers e.g. Ruby, Node and MongoDB.
The nodejs template looks as follows:
To deploy it, you can run:
As this template lives in a repo, we could have also run this from source as described in section 1.1
1.4 Creating an app from the OpenShift UI
If you're not a fan of the cli and wanted a more visual way of deploying applications in your cluster, you also have the option of using the OpenShift console. This is available locally at the address given after running minishift start
as we did in the setup:
Login to the UI:
As mentioned in the minishift start
output, you can use the user developer and password as any string of characters (at least one) and you will be able to access the UI.
Access the catalog:
Once you login, you will be redirected to the browser catalog where there will be a number of sample applications available for you to chose to deploy. This mirrors the OpenShift template steps we saw in section 1.2. We can also create and switch between projects but note, you are limited to the provided sample applications available in the console catalog.
See this reference for a more comprehensive overview of how to use the new-app
command to create OpenShift applications.
Congratulations! You have learnt several ways to create applications in OpenShift! To see how we can manage our applications in OpenShift, let's continue on to the next Lab (Lab 3)
Last updated
Was this helpful?