Openshift – Deploy First Application
Hope you’re doing well. I’m going to write a series of articles on quick reference for Openshift. To check all other related articles please visit here. In this article we’ll deploy a simple application on Openshift cluster using oc new-app command.
Let’s understand oc new-app command with a example, run below command in your local and observe output :
#Passing Git Repo as a argument to new-app command oc new-project myproject oc new-app https://github.com/sclorg/cakephp-ex The command will create below resources (run oc get all command), NAME READY STATUS RESTARTS AGE pod/cakephp-ex-1-build 0/1 Completed 0 2m pod/cakephp-ex-1-whxhr 1/1 Running 0 7s NAME DESIRED CURRENT READY AGE replicationcontroller/cakephp-ex-1 1 1 1 8s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/cakephp-ex ClusterIP 172.30.1.243 <none> 8080/TCP,8443/TCP 2m NAME REVISION DESIRED CURRENT TRIGGERED BY deploymentconfig.apps.openshift.io/cakephp-ex 1 1 1 config,image(cakephp-ex:latest) NAME TYPE FROM LATEST buildconfig.build.openshift.io/cakephp-ex Source Git 1 NAME TYPE FROM STATUS STARTED DURATION build.build.openshift.io/cakephp-ex-1 Source Git@458ec0d Complete 2 minutes ago 2m51s NAME DOCKER REPO TAGS UPDATED imagestream.image.openshift.io/cakephp-ex 172.30.1.1:5000/myproject/cakephp-ex latest 9 seconds ago #Passing Container Image location to new-app command oc new-project mynewproject oc new-app registry.hub.docker.com/sanketmodi/openshift-practice:hello-world The command will create below resources (run oc get all command), NAME READY STATUS RESTARTS AGE pod/openshift-practice-1-dkmqf 1/1 Running 0 10s NAME DESIRED CURRENT READY AGE replicationcontroller/openshift-practice-1 1 1 1 10s NAME REVISION DESIRED CURRENT TRIGGERED BY deploymentconfig.apps.openshift.io/openshift-practice 1 1 1 config,image(openshift-practice:hello-world) NAME DOCKER REPO TAGS UPDATED imagestream.image.openshift.io/openshift-practice 172.30.1.1:5000/mynewproject/openshift-practice hello-world 11 seconds ago
Let’s understand what exactly happened in both the cases,
1. Passing git repo as argument :
When we passed git repo as argument, oc-new app command identified that there’s some code to be build. So it created a build configuration to build the project and generate image from the same. Once build was complete it created deployment configuration to get image and run the same.
2. Passing image as argument :
When we passed image as argument, oc new-app command identified that it’s a runnable image. So it directly created deployment configuration to download and run that image.
Build Configuration – Manages build process which creates container image.
Deployment Configuration – Manages deployment process (Running above created container.)
These two are primary resources which gets created based on the input type, there are few other auxiliary services like Image Stream, Services, Routes etc, few are created by default and others can be created when required. In above example, imagestream was created in both the cases, because openshift does tag management internally and doesn’t rely on outer source for the image.
That’s it for this article, I hope this article gave you a brief introduction on deploying application on openshift. Please let me know if you have any doubt / query in comment. For more articles on Openshift please visit quick reference page. Keep Learning, Keep Sharing and Stay Safe.