Added install notes

This commit is contained in:
brennv 2016-04-04 13:17:54 -07:00
parent 52f724e12a
commit c3d600a041

View file

@ -1,15 +1,32 @@
Node.js sample app on OpenShift! 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" $ 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 $ 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). 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 $ 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. 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 $ 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 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 <none> 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/<name> --hostname=<www.example.com>
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. 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 $ oc delete all -l name=myapp
To remove all the resources with the label "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). 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: 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: