Browse code

Added Node.js simple example workflow

updated with smarterclayton feedback

Updated for official repo

sspeiche authored on 2015/04/23 21:42:06
Showing 2 changed files
... ...
@@ -7,3 +7,4 @@ available on top of Kubernetes and Docker.
7 7
 * [Hello OpenShift](./hello-openshift) is a simple Hello World style application that can be used to start a simple pod
8 8
 * [OpenShift Sample](./sample-app) is an end-to-end application demonstrating the full
9 9
   OpenShift v3 concept chain - images, builds, deployments, and templates.
10
+* [Node.js echo Sample](./nodejs-echo) highlights the simple workflow from creating project, new app from GitHub, building, deploying, running and updating.
10 11
new file mode 100644
... ...
@@ -0,0 +1,54 @@
0
+Node.js `echo` Service on OpenShift!
1
+-----------------
2
+
3
+This example will serve an http response of various "machine" stats from the "machine" the Node.js app is running on to [http://host:8080](http://host:8080).
4
+
5
+### OpenShift setup ###
6
+
7
+I just used the Docker all-in-one launch as described in the [origins project](https://github.com/openshift/origins).
8
+
9
+### The project ###
10
+
11
+If you don't have a project setup all ready, go ahead and take care of that
12
+
13
+        $ osc new-project nodejs-echo --display-name="nodejs-echo" --description="Sample Node.js app"
14
+
15
+That's it, project has been created.  Though it would probably be good to set your current project to this, such as:
16
+
17
+        $ osc project nodejs-echo
18
+
19
+### The app ###
20
+
21
+Now let's pull in the app source code from [GitHub repo](https://github.com/openshift/nodejs-example) (fork if you like)
22
+
23
+#### create ####
24
+
25
+        $ osc new-app https://github.com/openshift/nodejs-example
26
+        
27
+That should be it, `new-app` will take care of creating the right build configuration, deployment configuration and service definition.  Next you'll be able to kick off the build.
28
+
29
+Note, you can follow along with the web console (located at https://ip-address:8443/console) to see what new resources have been created and watch the progress of the build and deployment.
30
+
31
+#### build ####
32
+
33
+        $ osc start-build nodejs-echo --follow
34
+
35
+You can alternatively leave off `--follow` and use `osc build-logs nodejs-echo-n` where n is the number of the build (output of start-build).
36
+
37
+#### deploy #### 
38
+
39
+happens automatically, to monitor its status either watch the web console or `osc get pods` to see when the pod is up.  Another helpful command is
40
+
41
+        $ osc status
42
+
43
+This will help indicate what IP address the service is running, the default port for it to deploy at is 8080.  
44
+
45
+#### enjoy ####
46
+
47
+Run/test our app by simply doing an HTTP GET request
48
+
49
+        $ curl ip-address:8080
50
+
51
+#### update ####
52
+
53
+Assuming you used the URL of your own forked report, we can easily push changes to that hosted repo and simply repeat the steps above to build (this is obviously just demonstrating the manually kicking off of builds) which will trigger the new built image to be deployed.