OpenShift - Deploy an application from a build

An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.

There are various ways to deploy an app.

Before importing an image, the oc get images command can be used to determine if the image has already been imported.

~]# oc get images
NAME                                                                      IAMGE REFERENCE
sha256:0089883f8e4387618946cd24378a447b8cf7e5dfaa146b94acab27fc5e170a14   registry.example.com/jboss-webserver-3/webserver30-tomcat8-openshift@sha256:0089883f8e4387618946cd24378a447b8cf7e5dfaa146b94acab27fc5e170a14
sha256:0155e28b6b10d6fba7144df9ce33105acbab32766836baacc67c76b900a58772   registry.example.com/redhat-sso-7/sso70-openshift@sha256:0155e28b6b10d6fba7144df9ce33105acbab32766836baacc67c76b900a58772
sha256:03416282b034b93614ab2af74441ce481226bcf0b0b6c614cacd1b6f008f9792   registry.example.com/jboss-eap-6/eap64-openshift@sha256:03416282b034b93614ab2af74441ce481226bcf0b0b6c614cacd1b6f008f9792
sha256:03795eb1e54f94ffb822b8b3997b5f5bbeaa20bdf7006841864738d1eb58054b   registry.example.com/rhpam-7/rhpam72-businesscentral-openshift@sha256:03795eb1e54f94ffb822b8b3997b5f5bbeaa20bdf7006841864738d1eb58054b

 

The oc new-build command can be used to import an image from an external registry, such as GitHub. In this example, an image named camel-app is imported.

~]$ oc new-build fabric8/s2i-java~https://github.com/monodot/simple-camel-spring-boot-app --name=camel-app
--> Found container image ec41b73 (20 months old) from Docker Hub for "fabric8/s2i-java"

    Java Applications 
    ----------------- 
    Platform for building and running plain Java applications (fat-jar and flat classpath)

    Tags: builder, java

    * An image stream tag will be created as "s2i-java:latest" that will track the source image
    * A source build using source code from https://github.com/monodot/simple-camel-spring-boot-app will be created
      * The resulting image will be pushed to image stream tag "my-demo-app:latest"
      * Every time "s2i-java:latest" changes a new build will be triggered

--> Creating resources with label build=camel-app ...
    imagestream.image.openshift.io "s2i-java" created
    imagestream.image.openshift.io "camel-app" created
    buildconfig.build.openshift.io "camel-app" created
--> Success

 

The oc get builds command can then be used to determine if the build is running.

~]$ oc get builds
NAME               TYPE     FROM   STATUS                       STARTED         DURATION
camel-app-1        Source   Git    Running                      2 minutes ago

 

And the oc get imagestreams command should return something like this.

~]$ oc get is | grep -i demo
camel-app                                    image-registry.openshift-image-registry.svc:5000/foo/camel-app

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 1b444 in the box below so that we can be sure you are a human.