From ee1068b426fdfa6811fbde835ba6b6a6be2b6f53 Mon Sep 17 00:00:00 2001 From: gabemontero Date: Thu, 10 Mar 2016 17:08:43 -0500 Subject: [PATCH 01/25] parameterize name --- openshift/templates/nodejs-mongodb.json | 31 +++++++++++++++---------- openshift/templates/nodejs.json | 31 +++++++++++++++---------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/openshift/templates/nodejs-mongodb.json b/openshift/templates/nodejs-mongodb.json index a8deefd..e352b15 100644 --- a/openshift/templates/nodejs-mongodb.json +++ b/openshift/templates/nodejs-mongodb.json @@ -17,7 +17,7 @@ "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "nodejs-mongodb-example", + "name": "${NAME}", "annotations": { "description": "Exposes and load balances the application pods" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "nodejs-mongodb-example" + "name": "${NAME}" } } }, @@ -39,13 +39,13 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "nodejs-mongodb-example" + "name": "${NAME}" }, "spec": { "host": "${APPLICATION_DOMAIN}", "to": { "kind": "Service", - "name": "nodejs-mongodb-example" + "name": "${NAME}" } } }, @@ -53,7 +53,7 @@ "kind": "ImageStream", "apiVersion": "v1", "metadata": { - "name": "nodejs-mongodb-example", + "name": "${NAME}", "annotations": { "description": "Keeps track of changes in the application image" } @@ -63,7 +63,7 @@ "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "nodejs-mongodb-example", + "name": "${NAME}", "annotations": { "description": "Defines how to build the application" } @@ -90,7 +90,7 @@ "output": { "to": { "kind": "ImageStreamTag", - "name": "nodejs-mongodb-example:latest" + "name": "${NAME}:latest" } }, "triggers": [ @@ -119,7 +119,7 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "nodejs-mongodb-example", + "name": "${NAME}", "annotations": { "description": "Defines how to deploy the application server" } @@ -138,7 +138,7 @@ ], "from": { "kind": "ImageStreamTag", - "name": "nodejs-mongodb-example:latest" + "name": "${NAME}:latest" } } }, @@ -148,13 +148,13 @@ ], "replicas": 1, "selector": { - "name": "nodejs-mongodb-example" + "name": "${NAME}" }, "template": { "metadata": { - "name": "nodejs-mongodb-example", + "name": "${NAME}", "labels": { - "name": "nodejs-mongodb-example" + "name": "${NAME}" } }, "spec": { @@ -336,6 +336,13 @@ } ], "parameters": [ + { + "name": "NAME", + "displayName": "Name", + "description": "The name assigned to all of the frontend objects defined in this template.", + "required": true, + "value": "nodejs-mongodb-example" + }, { "name": "MEMORY_LIMIT", "displayName": "Memory Limit", diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json index 5a52441..da16ec1 100644 --- a/openshift/templates/nodejs.json +++ b/openshift/templates/nodejs.json @@ -17,7 +17,7 @@ "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "nodejs-example", + "name": "${NAME}", "annotations": { "description": "Exposes and load balances the application pods" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "nodejs-example" + "name": "${NAME}" } } }, @@ -39,13 +39,13 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "nodejs-example" + "name": "${NAME}" }, "spec": { "host": "${APPLICATION_DOMAIN}", "to": { "kind": "Service", - "name": "nodejs-example" + "name": "${NAME}" } } }, @@ -53,7 +53,7 @@ "kind": "ImageStream", "apiVersion": "v1", "metadata": { - "name": "nodejs-example", + "name": "${NAME}", "annotations": { "description": "Keeps track of changes in the application image" } @@ -63,7 +63,7 @@ "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "nodejs-example", + "name": "${NAME}", "annotations": { "description": "Defines how to build the application" } @@ -90,7 +90,7 @@ "output": { "to": { "kind": "ImageStreamTag", - "name": "nodejs-example:latest" + "name": "${NAME}:latest" } }, "triggers": [ @@ -119,7 +119,7 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "nodejs-example", + "name": "${NAME}", "annotations": { "description": "Defines how to deploy the application server" } @@ -138,7 +138,7 @@ ], "from": { "kind": "ImageStreamTag", - "name": "nodejs-example:latest" + "name": "${NAME}:latest" } } }, @@ -148,13 +148,13 @@ ], "replicas": 1, "selector": { - "name": "nodejs-example" + "name": "${NAME}" }, "template": { "metadata": { - "name": "nodejs-example", + "name": "${NAME}", "labels": { - "name": "nodejs-example" + "name": "${NAME}" } }, "spec": { @@ -223,6 +223,13 @@ } ], "parameters": [ + { + "name": "NAME", + "displayName": "Name", + "description": "The name assigned to all of the frontend objects defined in this template.", + "required": true, + "value": "nodejs-example" + }, { "name": "MEMORY_LIMIT", "displayName": "Memory Limit", From bab042519e8e22944a949b70160cce491e151cef Mon Sep 17 00:00:00 2001 From: gabemontero Date: Mon, 14 Mar 2016 21:16:16 -0400 Subject: [PATCH 02/25] parameterize IS namespace --- openshift/templates/nodejs-mongodb.json | 10 ++++++++-- openshift/templates/nodejs.json | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/openshift/templates/nodejs-mongodb.json b/openshift/templates/nodejs-mongodb.json index e352b15..3298ef4 100644 --- a/openshift/templates/nodejs-mongodb.json +++ b/openshift/templates/nodejs-mongodb.json @@ -82,7 +82,7 @@ "sourceStrategy": { "from": { "kind": "ImageStreamTag", - "namespace": "openshift", + "namespace": "${NAMESPACE}", "name": "nodejs:0.10" } } @@ -261,7 +261,7 @@ ], "from": { "kind": "ImageStreamTag", - "namespace": "openshift", + "namespace": "${NAMESPACE}", "name": "mongodb:2.6" } } @@ -343,6 +343,12 @@ "required": true, "value": "nodejs-mongodb-example" }, + { + "name": "NAMESPACE", + "displayName": "Namespace", + "description": "The OpenShift Namespace where the ImageStream resides.", + "value": "openshift" + }, { "name": "MEMORY_LIMIT", "displayName": "Memory Limit", diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json index da16ec1..82df67c 100644 --- a/openshift/templates/nodejs.json +++ b/openshift/templates/nodejs.json @@ -82,7 +82,7 @@ "sourceStrategy": { "from": { "kind": "ImageStreamTag", - "namespace": "openshift", + "namespace": "${NAMESPACE}", "name": "nodejs:0.10" } } @@ -230,6 +230,12 @@ "required": true, "value": "nodejs-example" }, + { + "name": "NAMESPACE", + "displayName": "Namespace", + "description": "The OpenShift Namespace where the ImageStream resides.", + "value": "openshift" + }, { "name": "MEMORY_LIMIT", "displayName": "Memory Limit", From 52f724e12a95776604dd20b3d3fd780eff15a55e Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 10:03:49 -0700 Subject: [PATCH 03/25] Corrects project name Fixes error: A project named "nodejs" does not exist on "https://10.2.2.2:8443". --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5416620..29516e0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ After logging in with `oc login`, if you don't have a project setup all ready, g That's it, project has been created. Though it would probably be good to set your current project to this (thought new-project does it automatically as well), such as: - $ oc project nodejs + $ oc project nodejs-echo ### The app ### From c3d600a0417b68fede7bef5a33b43cac04d3b1e4 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 13:17:54 -0700 Subject: [PATCH 04/25] Added install notes --- README.md | 82 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 29516e0..9f6c5ff 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,32 @@ Node.js sample app on OpenShift! ----------------- -This example will serve a welcome page and the current hit count as stored in a database to [http://host:8080](http://host:8080). +This example will serve a welcome page and the current hit count as stored in a database. -### OpenShift setup ### +### OpenShift v3 setup -One option is to use the Docker all-in-one launch as described in the [OpenShift Origin project](https://github.com/openshift/origin). +There are four methods to get started with OpenShift v3: running a virtual machine with Vagrant, starting a Docker continer, downloading the binary, or running an Ansible playbook. -### The project ### +Vagrant into a Virtual Machine -After logging in with `oc login`, if you don't have a project setup all ready, go ahead and take care of that +One option is to use the Vagrant all-in-one launch as described in the [OpenShift Origin All-In-One Virtual Machine](https://www.openshift.org/vm/). This option works on Mac, Windows and Linux, but requires that you install [Vagrant](https://www.vagrantup.com/downloads.html) running [VirtualBox](https://www.virtualbox.org/wiki/Downloads). + +Running a Docker Container + +Another option is running the OpenShift Origin Docker container image from [Docker Hub](https://hub.docker.com/r/openshift/origin/) launch as described in the [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#running-in-a-docker-container). This method is supported on Fedora, CentOS, and Red Hat Enterprise Linux (RHEL) hosts only. + +Downloading the Binary + +Red Hat periodically publishes OpenShift Origin Server binaries for Linux, which you can download on the OpenShift Origin GitHub [Release](https://github.com/openshift/origin/releases) page. Instructions on how to install and launch the Openshift Origin Server from binary are described in [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#downloading-the-binary). + +Running Ansible + +Outlined as the [Advanced Intallation](https://docs.openshift.org/latest/install_config/install/advanced_install.html) method for poduction environments, OpenShift Origin is also installable via Ansible playbook made avaialble on the GitHub [openShift-ansible](https://github.com/openshift/openshift-ansible) repo. + + +### The project + +After logging in with `oc login` (default username/password: openshift), if you don't have a project setup all ready, go ahead and take care of that $ oc new-project nodejs-echo --display-name="nodejs" --description="Sample Node.js app" @@ -17,60 +34,79 @@ That's it, project has been created. Though it would probably be good to set yo $ oc project nodejs-echo -### The app ### +### The app Now let's pull in the app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). -#### create #### +#### create $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp That should be it, this form of `new-app` will locate an appropriate image on DockerHub, create an ImageStream for that image, and then create the right build configuration, deployment configuration and service definition. Next you'll be able to kick off the build, though new-app will kick off a build once all required dependencies are confirmed. The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later. -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. +Check the status of your new nodejs app with the command: -#### build #### + $ oc status + +Which should return something like: -If the build is not started (you can check by running "oc get builds"), start one and stream the logs with: + $ In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 + +Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of the build and deployment. + +#### build + +If the build is not yet started (you can check by running `oc get builds`), start one and stream the logs with: $ oc start-build nodejs-ex --follow -You can alternatively leave off `--follow` and use `oc build-logs nodejs-ex-n` where n is the number of the build to track the output of the build. +You can alternatively leave off `--follow` and use `oc build-logs nodejs-ex-n` where *n* is the number of the build to track the output of the build. -#### deploy #### +#### deploy Deployment happens automatically once the new application image is available. To monitor its status either watch the web console or execute `oc get pods` to see when the pod is up. Another helpful command is - $ oc status + $ oc get svc -This will help indicate what IP address the service is running, the default port for it to deploy at is 8080. +This will help indicate what IP address the service is running, the default port for it to deploy at is 8080. Output should look like: -#### enjoy #### + $ NAME CLUSTER-IP EXTERNAL-IP PORT(S) SELECTOR AGE + $ nodejs-ex 172.30.249.251 8080/TCP deploymentconfig=nodejs-ex,name=myapp 17m + +#### route -Determine the service ip for the application by running +An OpenShift route exposes a service at a host name, like www.example.com, so that external clients can reach it by name. - $ oc get svc +DNS resolution for a host name is handled separately from routing; your administrator may have configured a cloud domain that will always correctly resolve to the OpenShift router, or if using an unrelated host name you may need to modify its DNS records independently to resolve to the router. -Run/test your app by browsing to +As of OpenShift v3.1 routes can be configured in the web console or via CLI. Using the CLI, you can expose a route as follows: - $ curl service-ip-address:8080 + $ oc expose service/ --hostname= + +If you're running OpenShift on a local machine, you can preview the new app by setting a local route like: -#### update #### + $ oc expose service/nodejs-ex --hostname=10.2.2.2 + +#### enjoy + +This example will serve a welcome page and the current hit count as stored in a database to [http://10.2.2.2](http://10.2.2.2). + +#### update 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 which will trigger the new built image to be deployed. -#### delete #### +#### delete $ oc delete all -l name=myapp To remove all the resources with the label "name=myapp". -###Debugging Unexpected Failures +### Debugging Unexpected Failures Review some of the common tips and suggestions [here](https://github.com/openshift/origin/blob/master/docs/debugging-openshift.md). -### Web UI ### +### Web UI To run this example from the Web UI, you can same steps following done on the CLI as defined above by [The project](#the-project). Here's a video showing it in motion: From 53a510899aa171c2f898c1424673e3bdb9986b39 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 14:46:02 -0700 Subject: [PATCH 05/25] Adding mongodb service (Hmmm, now restart everything and it automagically works? Or add the mongodb url to the nodejs pod some how?) --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 9f6c5ff..927b304 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,16 @@ As of OpenShift v3.1 routes can be configured in the web console or via CLI. Usi If you're running OpenShift on a local machine, you can preview the new app by setting a local route like: $ oc expose service/nodejs-ex --hostname=10.2.2.2 + +#### database + +You may have noticed the "Page view count" reads "No database configured". Let's fix that by adding a MongoDB pod: + + $ oc new-app -e \ + $ MONGODB_USER=admin,MONGODB_DATABASE=mongo_db,MONGODB_PASSWORD=secret,MONGODB_ADMIN_PASSWORD=super-secret \ + $ centos/mongodb-26-centos7 + +(Database work to be continued...) #### enjoy From d9c8c2e5e0e9f433f2ccfec5b2a4e103004a94b0 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 14:49:43 -0700 Subject: [PATCH 06/25] Formatting --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 927b304..647e507 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,19 @@ This example will serve a welcome page and the current hit count as stored in a There are four methods to get started with OpenShift v3: running a virtual machine with Vagrant, starting a Docker continer, downloading the binary, or running an Ansible playbook. -Vagrant into a Virtual Machine +#### Vagrant into a Virtual Machine One option is to use the Vagrant all-in-one launch as described in the [OpenShift Origin All-In-One Virtual Machine](https://www.openshift.org/vm/). This option works on Mac, Windows and Linux, but requires that you install [Vagrant](https://www.vagrantup.com/downloads.html) running [VirtualBox](https://www.virtualbox.org/wiki/Downloads). -Running a Docker Container +#### Run a Docker Container Another option is running the OpenShift Origin Docker container image from [Docker Hub](https://hub.docker.com/r/openshift/origin/) launch as described in the [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#running-in-a-docker-container). This method is supported on Fedora, CentOS, and Red Hat Enterprise Linux (RHEL) hosts only. -Downloading the Binary +#### Download the Binary Red Hat periodically publishes OpenShift Origin Server binaries for Linux, which you can download on the OpenShift Origin GitHub [Release](https://github.com/openshift/origin/releases) page. Instructions on how to install and launch the Openshift Origin Server from binary are described in [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#downloading-the-binary). -Running Ansible +#### Run Ansible Outlined as the [Advanced Intallation](https://docs.openshift.org/latest/install_config/install/advanced_install.html) method for poduction environments, OpenShift Origin is also installable via Ansible playbook made avaialble on the GitHub [openShift-ansible](https://github.com/openshift/openshift-ansible) repo. From dd22958804f2913b588e13e8d397ffea401ca246 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 16:01:48 -0700 Subject: [PATCH 07/25] Testing mongoldb config --- openshift/templates/nodejs.json | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json index 82df67c..61eda27 100644 --- a/openshift/templates/nodejs.json +++ b/openshift/templates/nodejs.json @@ -191,23 +191,27 @@ "env": [ { "name": "DATABASE_SERVICE_NAME", - "value": "${DATABASE_SERVICE_NAME}" + "value": "mongodb-26-centos7" }, { "name": "MONGODB_USER", - "value": "${MONGODB_USER}" + "value": "admin" }, { "name": "MONGODB_PASSWORD", - "value": "${MONGODB_PASSWORD}" + "value": "secret" }, { "name": "MONGODB_DATABASE", - "value": "${MONGODB_DATABASE}" + "value": "mongo_db" }, { "name": "MONGODB_ADMIN_PASSWORD", - "value": "${MONGODB_ADMIN_PASSWORD}" + "value": "super-secret" + }, + { + "name": "MONGODB_URL", + "value": "172.30.27.142:27017" } ], "resources": { From b9d2a51ad505714521650467b2fbc9c56f83a804 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 16:11:50 -0700 Subject: [PATCH 08/25] Reverted test configs --- openshift/templates/nodejs.json | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json index 61eda27..82df67c 100644 --- a/openshift/templates/nodejs.json +++ b/openshift/templates/nodejs.json @@ -191,27 +191,23 @@ "env": [ { "name": "DATABASE_SERVICE_NAME", - "value": "mongodb-26-centos7" + "value": "${DATABASE_SERVICE_NAME}" }, { "name": "MONGODB_USER", - "value": "admin" + "value": "${MONGODB_USER}" }, { "name": "MONGODB_PASSWORD", - "value": "secret" + "value": "${MONGODB_PASSWORD}" }, { "name": "MONGODB_DATABASE", - "value": "mongo_db" + "value": "${MONGODB_DATABASE}" }, { "name": "MONGODB_ADMIN_PASSWORD", - "value": "super-secret" - }, - { - "name": "MONGODB_URL", - "value": "172.30.27.142:27017" + "value": "${MONGODB_ADMIN_PASSWORD}" } ], "resources": { From 4fd0c003f6fd99c25cc60d92a3353728df9eb1c7 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 16:54:23 -0700 Subject: [PATCH 09/25] testing mongo configs --- openshift/templates/nodejs.json | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json index 82df67c..a9265f4 100644 --- a/openshift/templates/nodejs.json +++ b/openshift/templates/nodejs.json @@ -191,23 +191,27 @@ "env": [ { "name": "DATABASE_SERVICE_NAME", - "value": "${DATABASE_SERVICE_NAME}" + "value": "mongodb-26-centos7" }, { "name": "MONGODB_USER", - "value": "${MONGODB_USER}" + "value": "admin" }, { "name": "MONGODB_PASSWORD", - "value": "${MONGODB_PASSWORD}" + "value": "secret" }, { "name": "MONGODB_DATABASE", - "value": "${MONGODB_DATABASE}" + "value": "mongo_db" }, { "name": "MONGODB_ADMIN_PASSWORD", - "value": "${MONGODB_ADMIN_PASSWORD}" + "value": "super-secret" + }, + { + "name": "MONGODB_URL", + "value": "172.30.27.142" } ], "resources": { From 1fe477db293617fa0b118f19fc952335a48ddfa3 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 16:59:54 -0700 Subject: [PATCH 10/25] Reverted test configs --- openshift/templates/nodejs.json | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/openshift/templates/nodejs.json b/openshift/templates/nodejs.json index a9265f4..82df67c 100644 --- a/openshift/templates/nodejs.json +++ b/openshift/templates/nodejs.json @@ -191,27 +191,23 @@ "env": [ { "name": "DATABASE_SERVICE_NAME", - "value": "mongodb-26-centos7" + "value": "${DATABASE_SERVICE_NAME}" }, { "name": "MONGODB_USER", - "value": "admin" + "value": "${MONGODB_USER}" }, { "name": "MONGODB_PASSWORD", - "value": "secret" + "value": "${MONGODB_PASSWORD}" }, { "name": "MONGODB_DATABASE", - "value": "mongo_db" + "value": "${MONGODB_DATABASE}" }, { "name": "MONGODB_ADMIN_PASSWORD", - "value": "super-secret" - }, - { - "name": "MONGODB_URL", - "value": "172.30.27.142" + "value": "${MONGODB_ADMIN_PASSWORD}" } ], "resources": { From 8a6c05bbc7979d8fa636137df0814bc54c670387 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 4 Apr 2016 21:10:23 -0700 Subject: [PATCH 11/25] Added database instructions --- README.md | 98 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 647e507..a0034fc 100644 --- a/README.md +++ b/README.md @@ -5,56 +5,62 @@ This example will serve a welcome page and the current hit count as stored in a ### OpenShift v3 setup -There are four methods to get started with OpenShift v3: running a virtual machine with Vagrant, starting a Docker continer, downloading the binary, or running an Ansible playbook. +There are four methods to get started with OpenShift v3: -#### Vagrant into a Virtual Machine + - Running a virtual machine with Vagrant + - Starting a Docker container + - Downloading the binary + - Running an Ansible playbook + +#### Running a virtual machine with Vagrant One option is to use the Vagrant all-in-one launch as described in the [OpenShift Origin All-In-One Virtual Machine](https://www.openshift.org/vm/). This option works on Mac, Windows and Linux, but requires that you install [Vagrant](https://www.vagrantup.com/downloads.html) running [VirtualBox](https://www.virtualbox.org/wiki/Downloads). -#### Run a Docker Container +#### Starting a Docker container Another option is running the OpenShift Origin Docker container image from [Docker Hub](https://hub.docker.com/r/openshift/origin/) launch as described in the [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#running-in-a-docker-container). This method is supported on Fedora, CentOS, and Red Hat Enterprise Linux (RHEL) hosts only. -#### Download the Binary +#### Downloading the Binary Red Hat periodically publishes OpenShift Origin Server binaries for Linux, which you can download on the OpenShift Origin GitHub [Release](https://github.com/openshift/origin/releases) page. Instructions on how to install and launch the Openshift Origin Server from binary are described in [Getting Started for Administrators](https://docs.openshift.org/latest/getting_started/administrators.html#downloading-the-binary). -#### Run Ansible +#### Running an Ansible playbook Outlined as the [Advanced Intallation](https://docs.openshift.org/latest/install_config/install/advanced_install.html) method for poduction environments, OpenShift Origin is also installable via Ansible playbook made avaialble on the GitHub [openShift-ansible](https://github.com/openshift/openshift-ansible) repo. -### The project +### Creating a project After logging in with `oc login` (default username/password: openshift), if you don't have a project setup all ready, go ahead and take care of that - $ oc new-project nodejs-echo --display-name="nodejs" --description="Sample Node.js app" + $ oc new-project nodejs-echo \ + $ --display-name="nodejs" --description="Sample Node.js app" That's it, project has been created. Though it would probably be good to set your current project to this (thought new-project does it automatically as well), such as: $ oc project nodejs-echo -### The app +### Configuring the web app Now let's pull in the app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). -#### create +#### Create a new app $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp - + That should be it, this form of `new-app` will locate an appropriate image on DockerHub, create an ImageStream for that image, and then create the right build configuration, deployment configuration and service definition. Next you'll be able to kick off the build, though new-app will kick off a build once all required dependencies are confirmed. The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later. Check the status of your new nodejs app with the command: $ oc status - + Which should return something like: - $ In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 - + In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 + Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of the build and deployment. -#### build +#### Build the app If the build is not yet started (you can check by running `oc get builds`), start one and stream the logs with: @@ -62,7 +68,7 @@ If the build is not yet started (you can check by running `oc get builds`), star You can alternatively leave off `--follow` and use `oc build-logs nodejs-ex-n` where *n* is the number of the build to track the output of the build. -#### deploy +#### Deploy the app Deployment happens automatically once the new application image is available. To monitor its status either watch the web console or execute `oc get pods` to see when the pod is up. Another helpful command is @@ -70,10 +76,10 @@ Deployment happens automatically once the new application image is available. T This will help indicate what IP address the service is running, the default port for it to deploy at is 8080. Output should look like: - $ NAME CLUSTER-IP EXTERNAL-IP PORT(S) SELECTOR AGE - $ nodejs-ex 172.30.249.251 8080/TCP deploymentconfig=nodejs-ex,name=myapp 17m - -#### route + NAME CLUSTER-IP EXTERNAL-IP PORT(S) SELECTOR AGE + nodejs-ex 172.30.249.251 8080/TCP deploymentconfig=nodejs-ex,name=myapp 17m + +#### Configure routing An OpenShift route exposes a service at a host name, like www.example.com, so that external clients can reach it by name. @@ -82,45 +88,57 @@ DNS resolution for a host name is handled separately from routing; your administ As of OpenShift v3.1 routes can be configured in the web console or via CLI. Using the CLI, you can expose a route as follows: $ oc expose service/ --hostname= - + If you're running OpenShift on a local machine, you can preview the new app by setting a local route like: $ oc expose service/nodejs-ex --hostname=10.2.2.2 - -#### database -You may have noticed the "Page view count" reads "No database configured". Let's fix that by adding a MongoDB pod: +#### Create a database - $ oc new-app -e \ - $ MONGODB_USER=admin,MONGODB_DATABASE=mongo_db,MONGODB_PASSWORD=secret,MONGODB_ADMIN_PASSWORD=super-secret \ - $ centos/mongodb-26-centos7 - -(Database work to be continued...) +You may have noticed the home page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service: -#### enjoy + $ oc new-app centos/mongodb-26-centos7 \ + $ -e MONGODB_USER=admin,MONGODB_DATABASE=mongo_db,MONGODB_PASSWORD=secret,MONGODB_ADMIN_PASSWORD=super-secret + +Running `oc status` will reveal the address of the newly created MongoDB database: + + In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 + + http://10.2.2.2 to pod port 8080-tcp (svc/nodejs-ex) + dc/nodejs-ex deploys istag/nodejs-ex:latest <- + bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 + deployment #1 deployed 12 minutes ago - 1 pod + + svc/mongodb-26-centos7 - 172.30.201.71:27017 + dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest + deployment #1 deployed 2 minutes ago - 1 pod + + +Remove all the nodejs-ex resources with the label "name=myapp". + + $ oc delete all -l name=myapp + +Recreate the nodejs service again, but this time specifying the MONGO_URL environment variable: + + $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp \ + $ -e MONGO_URL=mongodb://admin:secret@172.30.201.71:27017/mongo_db + +#### Success This example will serve a welcome page and the current hit count as stored in a database to [http://10.2.2.2](http://10.2.2.2). -#### update +#### Pushing updates 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 which will trigger the new built image to be deployed. -#### delete - - $ oc delete all -l name=myapp - -To remove all the resources with the label "name=myapp". - -### Debugging Unexpected Failures +### Debugging Review some of the common tips and suggestions [here](https://github.com/openshift/origin/blob/master/docs/debugging-openshift.md). - ### Web UI To run this example from the Web UI, you can same steps following done on the CLI as defined above by [The project](#the-project). Here's a video showing it in motion: -OpenShift 3: Node.js Sample - From 3b95699528df831a95691708c7da1351521a7e80 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 11 Apr 2016 17:38:52 -0700 Subject: [PATCH 12/25] Adding template instructions --- README.md | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a0034fc..c1b8dc4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Node.js sample app on OpenShift! This example will serve a welcome page and the current hit count as stored in a database. -### OpenShift v3 setup +### OpenShift Origin v3 setup There are four methods to get started with OpenShift v3: @@ -40,15 +40,23 @@ That's it, project has been created. Though it would probably be good to set yo $ oc project nodejs-echo -### Configuring the web app +### Creating new apps -Now let's pull in the app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). +You can create a new OpenShift application using the web console or by running the `oc new-app` command from the CLI. With the OpenShift CLI there are three ways to create a new application, by specifying either: -#### Create a new app +- [source code](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-source-code) +- [OpenShift templates](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-a-template) +- [DockerHub images](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-an-image) + +#### Create a new app from source code (method 1) + +Pointing `oc new-app` at source code kicks off an automagic chain of events, for our example: $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp -That should be it, this form of `new-app` will locate an appropriate image on DockerHub, create an ImageStream for that image, and then create the right build configuration, deployment configuration and service definition. Next you'll be able to kick off the build, though new-app will kick off a build once all required dependencies are confirmed. The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later. +The tool will inspect the source code, locate an appropriate image on DockerHub, create an ImageStream for that image, and then create the right build configuration, deployment configuration and service definition. + +Next you'll be able to kick off the build, though new-app will kick off a build once all required dependencies are confirmed. The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later. Check the status of your new nodejs app with the command: @@ -58,8 +66,31 @@ Which should return something like: In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 -Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of the build and deployment. +Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of builds and deployments. +#### Create a new app from a template (method 2) + +We can also create new apps using OpenShift template files. Clone the demo app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). + + $ git clone https://github.com/openshift/nodejs-ex + +Looking at the repo, you'll notice two files in the openshift/template directory: + + nodejs-ex + ├── README.md + ├── openshift + │   └── templates + │   ├── nodejs-mongodb.json + │   └── nodejs.json + ├── package.json + ├── server.js + └── views + └── index.html + +We can create the the new app from the `nodejs.json` template by using the `-f` flag and pointing the tool at a path to the template file: + + $ oc new-app -f /path/to/nodejs.json + #### Build the app If the build is not yet started (you can check by running `oc get builds`), start one and stream the logs with: @@ -93,7 +124,7 @@ If you're running OpenShift on a local machine, you can preview the new app by s $ oc expose service/nodejs-ex --hostname=10.2.2.2 -#### Create a database +#### Create a new app from an image (method 3) You may have noticed the home page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service: From 3dcc516d0a2e7b3ae42d34db9a1307f9fc47eb2d Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 11 Apr 2016 17:50:38 -0700 Subject: [PATCH 13/25] Cleaning up --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c1b8dc4..006769d 100644 --- a/README.md +++ b/README.md @@ -56,21 +56,11 @@ Pointing `oc new-app` at source code kicks off an automagic chain of events, for The tool will inspect the source code, locate an appropriate image on DockerHub, create an ImageStream for that image, and then create the right build configuration, deployment configuration and service definition. -Next you'll be able to kick off the build, though new-app will kick off a build once all required dependencies are confirmed. The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later. - -Check the status of your new nodejs app with the command: - - $ oc status - -Which should return something like: - - In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 - -Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of builds and deployments. +(The -l flag will apply a label of "name=myapp" to all the resources created by new-app, for easy management later.) #### Create a new app from a template (method 2) -We can also create new apps using OpenShift template files. Clone the demo app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). +We can also [create new apps using OpenShift template files](https://docs.openshift.com/enterprise/3.0/dev_guide/new_app.html#specifying-a-template). Clone the demo app source code from [GitHub repo](https://github.com/openshift/nodejs-ex) (fork if you like). $ git clone https://github.com/openshift/nodejs-ex @@ -93,6 +83,18 @@ We can create the the new app from the `nodejs.json` template by using the `-f` #### Build the app +`oc new-app` will kick off a build once all required dependencies are confirmed. + +Check the status of your new nodejs app with the command: + + $ oc status + +Which should return something like: + + In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 + +Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of builds and deployments. + If the build is not yet started (you can check by running `oc get builds`), start one and stream the logs with: $ oc start-build nodejs-ex --follow From c9cbe7ea942bb16594e68f6f5c91137f8ae4a0a7 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 11 Apr 2016 17:59:14 -0700 Subject: [PATCH 14/25] More clean-up Done for now --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 006769d..fff7dae 100644 --- a/README.md +++ b/README.md @@ -128,12 +128,14 @@ If you're running OpenShift on a local machine, you can preview the new app by s #### Create a new app from an image (method 3) -You may have noticed the home page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service: +You may have noticed the home page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service. We could use the second OpenShift template example (`nodejs-mongodb.json`) but for the sake of demonstration let's point `oc new-app` at a DockerHub image: $ oc new-app centos/mongodb-26-centos7 \ $ -e MONGODB_USER=admin,MONGODB_DATABASE=mongo_db,MONGODB_PASSWORD=secret,MONGODB_ADMIN_PASSWORD=super-secret + +The `-e` flag sets the environment variables we want used in the configuration of our new app. -Running `oc status` will reveal the address of the newly created MongoDB database: +Running `oc status` will reveal the address of the newly created MongoDB: In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 From 5f6028f3c620b384f5cc29675e633163662989ad Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 11 Apr 2016 18:21:43 -0700 Subject: [PATCH 15/25] Minor clean-up --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fff7dae..00bb09b 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ You can create a new OpenShift application using the web console or by running t #### Create a new app from source code (method 1) -Pointing `oc new-app` at source code kicks off an automagic chain of events, for our example: +Pointing `oc new-app` at source code kicks off a chain of events, for our example run: $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp From 98a5af7c33afb036be0eb0799a8fdb96ba46c310 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 11 Apr 2016 18:30:33 -0700 Subject: [PATCH 16/25] Replaces "oc build-logs" with "oc logs" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00bb09b..e429abc 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ If the build is not yet started (you can check by running `oc get builds`), star $ oc start-build nodejs-ex --follow -You can alternatively leave off `--follow` and use `oc build-logs nodejs-ex-n` where *n* is the number of the build to track the output of the build. +You can alternatively leave off `--follow` and use `oc logs nodejs-ex-n` where *n* is the number of the build to track the output of the build. #### Deploy the app From 553ecee811b5204708731f4f07ad9925fbab74e1 Mon Sep 17 00:00:00 2001 From: brennv Date: Mon, 11 Apr 2016 18:32:42 -0700 Subject: [PATCH 17/25] Adds colon --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e429abc..7dca716 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Outlined as the [Advanced Intallation](https://docs.openshift.org/latest/install ### Creating a project -After logging in with `oc login` (default username/password: openshift), if you don't have a project setup all ready, go ahead and take care of that +After logging in with `oc login` (default username/password: openshift), if you don't have a project setup all ready, go ahead and take care of that: $ oc new-project nodejs-echo \ $ --display-name="nodejs" --description="Sample Node.js app" From 5aab9573320a8449f350e87953e5c04a22c6aca6 Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 03:58:46 -0700 Subject: [PATCH 18/25] Setting routes and environment variables --- README.md | 57 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 7dca716..f227d26 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,14 @@ Check the status of your new nodejs app with the command: Which should return something like: In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 + + svc/nodejs-ex - 172.30.108.183:8080 + dc/nodejs-ex deploys istag/nodejs-ex:latest <- + bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 + build #1 running for 7 seconds + deployment #1 waiting on image or update -Note the address, as yours may differ. This is the address for the web GUI console. You can follow along with the web console to see what new resources have been created and watch the progress of builds and deployments. +Note the server address for the web console, as yours will likely differ if you're not using the Vagrant set-up. You can follow along with the web console to see what new resources have been created and watch the progress of builds and deployments. If the build is not yet started (you can check by running `oc get builds`), start one and stream the logs with: @@ -116,51 +122,56 @@ This will help indicate what IP address the service is running, the default port An OpenShift route exposes a service at a host name, like www.example.com, so that external clients can reach it by name. -DNS resolution for a host name is handled separately from routing; your administrator may have configured a cloud domain that will always correctly resolve to the OpenShift router, or if using an unrelated host name you may need to modify its DNS records independently to resolve to the router. +DNS resolution for a host name is handled separately from routing; you may wish to configure a cloud domain that will always correctly resolve to the OpenShift router, or if using an unrelated host name you may need to modify its DNS records independently to resolve to the router. -As of OpenShift v3.1 routes can be configured in the web console or via CLI. Using the CLI, you can expose a route as follows: +That aside, let's explore our new web console, which for our example is running at [https://10.2.2.2:8443](https://10.2.2.2:8443). - $ oc expose service/ --hostname= +After logging into the web console with your same CLI `oc login` credentials, click on the project we just created, then click `Create route`. -If you're running OpenShift on a local machine, you can preview the new app by setting a local route like: +If you're running OpenShift on a local machine, you can preview the new app by setting the Hostname to a localhost like: *10.2.2.2*. - $ oc expose service/nodejs-ex --hostname=10.2.2.2 +Now navigate to the newly created Node.js web app at the hostname we just configured, for our example it was simply [https://10.2.2.2](https://10.2.2.2). #### Create a new app from an image (method 3) -You may have noticed the home page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service. We could use the second OpenShift template example (`nodejs-mongodb.json`) but for the sake of demonstration let's point `oc new-app` at a DockerHub image: +You may have noticed the index page "Page view count" reads "No database configured". Let's fix that by adding a MongoDB service. We could use the second OpenShift template example (`nodejs-mongodb.json`) but for the sake of demonstration let's point `oc new-app` at a DockerHub image: $ oc new-app centos/mongodb-26-centos7 \ $ -e MONGODB_USER=admin,MONGODB_DATABASE=mongo_db,MONGODB_PASSWORD=secret,MONGODB_ADMIN_PASSWORD=super-secret The `-e` flag sets the environment variables we want used in the configuration of our new app. -Running `oc status` will reveal the address of the newly created MongoDB: +Running `oc status` or checking the web console will reveal the address of the newly created MongoDB: - In project nodejs (nodejs-echo) on server https://10.2.2.2:8443 + In project nodejs-echo2 on server https://10.2.2.2:8443 + + svc/mongodb-26-centos7 - 172.30.0.112:27017 + dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest + deployment #1 running for 43 seconds - 1 pod + + http://10.2.2.2 to pod port 8080-tcp (svc/nodejs-ex) + dc/nodejs-ex deploys istag/nodejs-ex:latest <- + bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 + deployment #1 deployed 14 minutes ago - 1 pod + +Note that the url for our new Mongo instance, for our example, is `172.30.0.112:27017` -- your's will likely differ. - http://10.2.2.2 to pod port 8080-tcp (svc/nodejs-ex) - dc/nodejs-ex deploys istag/nodejs-ex:latest <- - bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 - deployment #1 deployed 12 minutes ago - 1 pod +#### Setting environment variables - svc/mongodb-26-centos7 - 172.30.201.71:27017 - dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest - deployment #1 deployed 2 minutes ago - 1 pod +To take a look at environment variables set for each pod, run `oc env pods --all --list`. + +We need to add the environment variable `MONGO_URL=mongodb://admin:secret@172.30.0.112:27017/mongo_db` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. -Remove all the nodejs-ex resources with the label "name=myapp". +... - $ oc delete all -l name=myapp +Trying variations on: `oc env pods/nodejs-ex-1-jrz3w MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db` -Recreate the nodejs service again, but this time specifying the MONGO_URL environment variable: - - $ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp \ - $ -e MONGO_URL=mongodb://admin:secret@172.30.201.71:27017/mongo_db +... #### Success -This example will serve a welcome page and the current hit count as stored in a database to [http://10.2.2.2](http://10.2.2.2). +This example will serve a Node.js welcome page and the current hit count as stored in a MongoDB database. #### Pushing updates From fe60336571744ef7422f5f018f14f6bddeb7546c Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 08:23:44 -0700 Subject: [PATCH 19/25] Adding environment instructions --- README.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f227d26..61dd13f 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,10 @@ After logging into the web console with your same CLI `oc login` credentials, cl If you're running OpenShift on a local machine, you can preview the new app by setting the Hostname to a localhost like: *10.2.2.2*. +This could also be accomplished by running: + + $ oc expose svc/nodejs-ex --hostname=www.example.com + Now navigate to the newly created Node.js web app at the hostname we just configured, for our example it was simply [https://10.2.2.2](https://10.2.2.2). #### Create a new app from an image (method 3) @@ -160,18 +164,27 @@ Note that the url for our new Mongo instance, for our example, is `172.30.0.112: To take a look at environment variables set for each pod, run `oc env pods --all --list`. -We need to add the environment variable `MONGO_URL=mongodb://admin:secret@172.30.0.112:27017/mongo_db` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. +We need to add the environment variable `MONGO_URL=mongodb://admin:secret@172.30.0.112:27017/mongo_db` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. Run: - -... - -Trying variations on: `oc env pods/nodejs-ex-1-jrz3w MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db` - -... + $ oc env dc/nodejs-ex MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db' + +Then check `oc status` to see that an updated deployment has been kicked off: + + In project nodejs-echo2 on server https://10.2.2.2:8443 + + svc/mongodb-26-centos7 - 172.30.0.112:27017 + dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest + deployment #1 deployed 2 hours ago - 1 pod + + http://10.2.2.2 to pod port 8080-tcp (svc/nodejs-ex) + dc/nodejs-ex deploys istag/nodejs-ex:latest <- + bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 + deployment #2 deployed about a minute ago - 1 pod + deployment #1 deployed 2 hours ago #### Success -This example will serve a Node.js welcome page and the current hit count as stored in a MongoDB database. +You should now have a Node.js welcome page showing the current hit count, as stored in a MongoDB database. #### Pushing updates From ed10551d61c88615ffb5a15446e287b7c74cf57f Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 08:32:43 -0700 Subject: [PATCH 20/25] Clean up --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61dd13f..a997a64 100644 --- a/README.md +++ b/README.md @@ -158,13 +158,13 @@ Running `oc status` or checking the web console will reveal the address of the n bc/nodejs-ex builds https://github.com/openshift/nodejs-ex with openshift/nodejs:0.10 deployment #1 deployed 14 minutes ago - 1 pod -Note that the url for our new Mongo instance, for our example, is `172.30.0.112:27017` -- your's will likely differ. +Note that the url for our new Mongo instance, for our example, is `172.30.0.112:27017`, your's will likely differ. #### Setting environment variables To take a look at environment variables set for each pod, run `oc env pods --all --list`. -We need to add the environment variable `MONGO_URL=mongodb://admin:secret@172.30.0.112:27017/mongo_db` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. Run: +We need to add the environment variable `MONGO_URL` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. Run: $ oc env dc/nodejs-ex MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db' From 0e2fbd8c66b80ff2892bff431f92ae9fa2c76341 Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 08:37:00 -0700 Subject: [PATCH 21/25] Minor edits --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a997a64..f69cd5a 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ The `-e` flag sets the environment variables we want used in the configuration o Running `oc status` or checking the web console will reveal the address of the newly created MongoDB: - In project nodejs-echo2 on server https://10.2.2.2:8443 + In project nodejs-echo on server https://10.2.2.2:8443 svc/mongodb-26-centos7 - 172.30.0.112:27017 dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest @@ -170,7 +170,7 @@ We need to add the environment variable `MONGO_URL` to our Node.js web app so th Then check `oc status` to see that an updated deployment has been kicked off: - In project nodejs-echo2 on server https://10.2.2.2:8443 + In project nodejs-echo on server https://10.2.2.2:8443 svc/mongodb-26-centos7 - 172.30.0.112:27017 dc/mongodb-26-centos7 deploys istag/mongodb-26-centos7:latest From 2cdcf150e5ec1d13e526a221ad076d3aa552e072 Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 08:39:31 -0700 Subject: [PATCH 22/25] Removed missing reference --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f69cd5a..cff86c3 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ Review some of the common tips and suggestions [here](https://github.com/openshi ### Web UI -To run this example from the Web UI, you can same steps following done on the CLI as defined above by [The project](#the-project). Here's a video showing it in motion: +To run this example from the Web UI, you can same steps following done on the CLI as defined above. Here's a video showing it in motion: Date: Tue, 12 Apr 2016 11:31:37 -0700 Subject: [PATCH 23/25] Fixed oc commands Added "set" to env and "build/" to logs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cff86c3..f591cc4 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ If the build is not yet started (you can check by running `oc get builds`), star $ oc start-build nodejs-ex --follow -You can alternatively leave off `--follow` and use `oc logs nodejs-ex-n` where *n* is the number of the build to track the output of the build. +You can alternatively leave off `--follow` and use `oc logs build/nodejs-ex-n` where *n* is the number of the build to track the output of the build. #### Deploy the app @@ -166,7 +166,7 @@ To take a look at environment variables set for each pod, run `oc env pods --all We need to add the environment variable `MONGO_URL` to our Node.js web app so that it will utilize our MongoDB, and enable the "Page view count" feature. Run: - $ oc env dc/nodejs-ex MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db' + $ oc set env dc/nodejs-ex MONGO_URL='mongodb://admin:secret@172.30.0.112:27017/mongo_db' Then check `oc status` to see that an updated deployment has been kicked off: From efb069d7caa76d7fb4ed752f2b643288375cd388 Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 12:27:38 -0700 Subject: [PATCH 24/25] Fixed grammar --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f591cc4..4437f41 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ You should now have a Node.js welcome page showing the current hit count, as sto #### Pushing updates -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 which will trigger the new built image to be deployed. +Assuming you used the URL of your own forked repository, we can easily push changes and simply repeat the steps above which will trigger the newly built image to be deployed. ### Debugging From def1abb3a4face2376dd34d593334163a4b4c69f Mon Sep 17 00:00:00 2001 From: brennv Date: Tue, 12 Apr 2016 13:42:17 -0700 Subject: [PATCH 25/25] Spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4437f41..d6f4377 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Red Hat periodically publishes OpenShift Origin Server binaries for Linux, which #### Running an Ansible playbook -Outlined as the [Advanced Intallation](https://docs.openshift.org/latest/install_config/install/advanced_install.html) method for poduction environments, OpenShift Origin is also installable via Ansible playbook made avaialble on the GitHub [openShift-ansible](https://github.com/openshift/openshift-ansible) repo. +Outlined as the [Advanced Installation](https://docs.openshift.org/latest/install_config/install/advanced_install.html) method for poduction environments, OpenShift Origin is also installable via Ansible playbook made avaialble on the GitHub [openShift-ansible](https://github.com/openshift/openshift-ansible) repo. ### Creating a project