You can use multiple methods to deploy applications in an OpenShift cluster. This guide provides some examples. For more information, see Creating applications using the Developer perspective in the OpenShift Container Platform documentation.
OpenShift supports application deployment using an image that is stored in an external image registry. Images have the necessary packages and program tools to run the applications by default.
To deploy an application that is already part of an image, complete the following steps. Unless specified otherwise, run all the commands as user core in CSAH.
[core@csah ~]$ oc login -u <user name>
[core@csah ~]$ oc new-project <project name>
[core@csah ~]$ oc new-app <image-name>
This guide uses openshift/hello-openshift for the image name that is being tested.
Figure 13. Sample application deployment status
OpenShift supports application deployment by using a source from GitHub and specifying an image. One good application example is Source-to-Image (S2I), a toolkit and workflow for building reproducible container images from source code. A build configuration is generated for the S2I deployment in a new pod called Build Pod. In the build configuration, you can configure the triggers that are required to automate the new build process every time a condition meets the specifications that you defined. After the deployment is complete, a new image with injected source code is created automatically.
Follow these steps to deploy an application using a source from GitHub. The source in the sample deployment is httpd-ex.
[core@csah ~]$ oc login -u <user name>
[core@csah ~]$ oc new-project <project name>
[core@csah ~]$ oc new-app centos/httpd-24-centos7~https://github.com/sclorg/httpd-ex.git
Note: The image is centos/httpd-24-centos7. The GitHub source is https://github.com/sclorg/httpd-ex.git. You can obtain build logs by running oc logs -f bc/httpd-ex for this example.
Figure 14. Sample S2I deployment status
[core@csah ~]$ oc get buildconfig httpd-ex -o yaml
You can access applications that are deployed within the OpenShift cluster using images or source code from GitHub by using the service IP address that is associated with the deployments. External access to the applications is not available by default.
To enable access to the applications from an external network:
[core@csah ~]$ oc login -u <user name>
[core@csah ~]$ oc project sample
Now using project "sample" on server "https://api.ocp.example.com:6443".
Note: Typically, the name of the service is the same as the name of the deployment.
[core@csah ~]$ oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-openshift ClusterIP 172.30.93.229 <none> 8080/TCP,8888/TCP 23m
[core@csah yaml]$ oc expose svc/hello-openshift
route.route.openshift.io/hello-openshift exposed
[core@csah ~]$ oc get routes
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
hello-openshift hello-openshift-sample.apps.ocp.example.com hello-openshift 8080-tcp None