When using OpenShift there are a number of different ways you can add an application. The main methods are:
- Deploy an application from an existing Docker-formatted image.
- Build and deploy from source code contained in a Git repository using a Source-to-Image builder.
- Build and deploy from source code contained in a Git repository from a Dockerfile.
In this course you will learn how to deploy an application from source code contained in a Git repository using a Source-to-Image builder.
The example application which will be deployed is implemented using the Python programming language. You will learn how to deploy the application from the OpenShift web console, and from the command line using
In this course you learnt about deploying an application from source code using a Source-to-Image (S2I) builder. You first deployed the application from the web console, following that up with using the command line. You also learnt about using binary input source builds to run builds using source code from a local directory on your own computer.
The web application you deployed was implemented using the Python programming language. OpenShift provides S2I builders for a number of different programming languages/frameworks in addition to Python. These include Java, NodeJS, Perl, PHP and Ruby.
You can find a summary of the key commands covered below. To see more information on each
oc command, run it with the
oc new-app <image:tag>~<source-code> --name <name>: Deploy an application from source code hosted on a Git repository using the specified S2I builder image.
oc start-build <name>: Trigger a new build and deployment of the application where source code is taken from the hosted Git repository specified to
oc new-app when the build configuration was created.
oc start-build <name> --from-dir=.: Trigger a new build and deployment of the application where source code is taken from the current working directory of the local machine where the
oc command is being run.
oc cancel-build <build>: Cancel a running build.
oc logs bc/<name> --follow: Monitor the log output from the current build for the application.
oc get builds: Display a list of all builds, completed, cancelled and running.
oc get builds --watch: Monitor the progress of any active builds.
oc get pods --watch: Monitor any activity related to pods in the project. This will include pods run to handle building and deployment of an application.
Deploying Applications From Source
Topic 1 - Creating an Initial Project
Before we get started, you need to login and create a project in OpenShift to work in.
To login to the OpenShift cluster used for this course from the Terminal, run:
oc login -u developer -p developer
This will log you in using the credentials:
You should see the output:
Login successful. You don't have any projects. You can try to create a new project, by running oc new-project <projectname>
To create a new project called
myproject run the command:
oc new-project myproject
You should see output similar to:
Now using project "myproject" on server "https://172.17.0.41:8443". You can add applications to this project with the 'new-app' command. For example, try: oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git to build a new example application in Ruby.
Switch to the Dashboard and login to the OpenShift web console using the same credentials you used above.
This should leave you at the list of projects you have access to. As we only
created the one project, all you should see is
myproject and you should be left at the Overview page for
As the project is currently empty, you should be presented with an Add to Project button.