Compare commits
No commits in common. "master" and "revert-112-revert-111-nodejs6" have entirely different histories.
master
...
revert-112
16 changed files with 87 additions and 334 deletions
68
README.md
68
README.md
|
@ -1,34 +1,4 @@
|
|||
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Node.js sample app on OpenShift!](#nodejs-sample-app-on-openshift)
|
||||
* [OpenShift Origin v3 setup](#openshift-origin-v3-setup)
|
||||
+ [Running a virtual machine with Vagrant](#running-a-virtual-machine-with-vagrant)
|
||||
+ [Running a virtual machine managed by minishift](#running-a-virtual-machine-managed-by-minishift)
|
||||
+ [Starting a Docker container](#starting-a-docker-container)
|
||||
+ [Downloading the Binary](#downloading-the-binary)
|
||||
+ [Running an Ansible playbook](#running-an-ansible-playbook)
|
||||
* [Creating a project](#creating-a-project)
|
||||
* [Creating new apps](#creating-new-apps)
|
||||
+ [Create a new app from source code (method 1)](#create-a-new-app-from-source-code-method-1)
|
||||
+ [Create a new app from a template (method 2)](#create-a-new-app-from-a-template-method-2)
|
||||
+ [Build the app](#build-the-app)
|
||||
+ [Deploy the app](#deploy-the-app)
|
||||
+ [Configure routing](#configure-routing)
|
||||
+ [Create a new app from an image (method 3)](#create-a-new-app-from-an-image-method-3)
|
||||
+ [Setting environment variables](#setting-environment-variables)
|
||||
+ [Success](#success)
|
||||
+ [Pushing updates](#pushing-updates)
|
||||
* [Debugging](#debugging)
|
||||
* [Web UI](#web-ui)
|
||||
* [Looking for help](#looking-for-help)
|
||||
* [Compatibility](#compatibility)
|
||||
* [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## 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.
|
||||
|
@ -38,30 +8,25 @@ 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
|
||||
- Running a virtual machine managed by minishift
|
||||
- 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.okd.io/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 virtual machine managed by minishift
|
||||
|
||||
Another option to run virtual machine but not having to using Vagrant is to download and use the `minishift` binary as described in its [getting started](https://github.com/minishift/minishift/#getting-started) section. `minishift` can be used to spin up a VM on any of Windows, Linux or Mac with the help of supported underlying virtualization technologies like KVM, xhyve, Hyper-V, VirtualBox.
|
||||
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).
|
||||
|
||||
#### 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.okd.io/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.
|
||||
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.okd.io/latest/getting_started/administrators.html#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 an Ansible playbook
|
||||
|
||||
Outlined as the [Advanced Installation](https://docs.okd.io/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
|
||||
|
@ -69,7 +34,7 @@ Outlined as the [Advanced Installation](https://docs.okd.io/latest/install_confi
|
|||
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"
|
||||
$ --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:
|
||||
|
||||
|
@ -87,7 +52,7 @@ You can create a new OpenShift application using the web console or by running t
|
|||
|
||||
Pointing `oc new-app` at source code kicks off a chain of events, for our example run:
|
||||
|
||||
$ oc new-app https://github.com/sclorg/nodejs-ex -l name=myapp
|
||||
$ oc new-app https://github.com/openshift/nodejs-ex -l name=myapp
|
||||
|
||||
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.
|
||||
|
||||
|
@ -95,9 +60,9 @@ The tool will inspect the source code, locate an appropriate image on DockerHub,
|
|||
|
||||
#### Create a new app from a template (method 2)
|
||||
|
||||
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/sclorg/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/sclorg/nodejs-ex
|
||||
$ git clone https://github.com/openshift/nodejs-ex
|
||||
|
||||
Looking at the repo, you'll notice three files in the openshift/template directory:
|
||||
|
||||
|
@ -133,7 +98,7 @@ Which should return something like:
|
|||
|
||||
svc/nodejs-ex - 172.30.108.183:8080
|
||||
dc/nodejs-ex deploys istag/nodejs-ex:latest <-
|
||||
bc/nodejs-ex builds https://github.com/sclorg/nodejs-ex with openshift/nodejs:0.10
|
||||
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
|
||||
|
||||
|
@ -179,7 +144,7 @@ Now navigate to the newly created Node.js web app at the hostname we just config
|
|||
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
|
||||
$ -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.
|
||||
|
||||
|
@ -193,7 +158,7 @@ Running `oc status` or checking the web console will reveal the address of the n
|
|||
|
||||
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/sclorg/nodejs-ex with openshift/nodejs:0.10
|
||||
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`, yours will likely differ.
|
||||
|
@ -216,7 +181,7 @@ Then check `oc status` to see that an updated deployment has been kicked off:
|
|||
|
||||
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/sclorg/nodejs-ex with openshift/nodejs:0.10
|
||||
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
|
||||
|
||||
|
@ -240,14 +205,11 @@ To run this example from the Web UI, you can same steps following done on the CL
|
|||
<img src="http://img.youtube.com/vi/uocucZqg_0I/0.jpg"
|
||||
alt="OpenShift 3: Node.js Sample" width="240" height="180" border="10" /></a>
|
||||
|
||||
### Looking for help
|
||||
## Looking for help
|
||||
|
||||
If you get stuck at some point, or think that this document needs further details or clarification, you can give feedback and look for help using the channels mentioned in [the OpenShift Origin repo](https://github.com/openshift/origin), or by filing an issue.
|
||||
|
||||
### Compatibility
|
||||
|
||||
This repository is compatible with Node.js 4 and higher, excluding any alpha or beta versions.
|
||||
|
||||
### License
|
||||
## License
|
||||
|
||||
This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to [CC0](http://creativecommons.org/publicdomain/zero/1.0/).
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
name: nodejs
|
||||
version: 0.1
|
||||
description: An example Node.js application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.
|
||||
keywords:
|
||||
- quickstart
|
||||
- nodejs
|
||||
home: https://access.redhat.com
|
||||
sources:
|
||||
- https://github.com/sclorg/nodejs-ex
|
|
@ -1,3 +0,0 @@
|
|||
The following service(s) have been created in your project: {{ .Values.name }}.
|
||||
|
||||
For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.
|
|
@ -1,38 +0,0 @@
|
|||
kind: BuildConfig
|
||||
apiVersion: build.openshift.io/v1
|
||||
metadata:
|
||||
name: {{ .Values.name | quote }}
|
||||
annotations:
|
||||
description: Defines how to build the application
|
||||
spec:
|
||||
source:
|
||||
type: Git
|
||||
git:
|
||||
uri: {{ .Values.source_repository_url | quote }}
|
||||
ref: {{ .Values.source_repository_ref | quote }}
|
||||
contextDir: {{ .Values.context_dir | quote }}
|
||||
strategy:
|
||||
type: Source
|
||||
sourceStrategy:
|
||||
from:
|
||||
kind: ImageStreamTag
|
||||
namespace: {{ .Values.namespace | quote }}
|
||||
name: nodejs:6
|
||||
env:
|
||||
- name: NPM_MIRROR
|
||||
value: {{ .Values.npm_mirror | quote }}
|
||||
output:
|
||||
to:
|
||||
kind: ImageStreamTag
|
||||
name: {{ print .Values.name ":latest" | quote }}
|
||||
triggers:
|
||||
- type: ImageChange
|
||||
- type: ConfigChange
|
||||
- type: GitHub
|
||||
github:
|
||||
secret: {{ .Values.github_webhook_secret | default (randAlphaNum 40) | quote }}
|
||||
- type: Generic
|
||||
generic:
|
||||
secret: {{ .Values.generic_webhook_secret | default (randAlphaNum 40) | quote }}
|
||||
postCommit:
|
||||
script: npm test
|
|
@ -1,49 +0,0 @@
|
|||
kind: DeploymentConfig
|
||||
apiVersion: apps.openshift.io/v1
|
||||
metadata:
|
||||
name: {{ .Values.name | quote }}
|
||||
annotations:
|
||||
description: Defines how to deploy the application server
|
||||
template.alpha.openshift.io/wait-for-ready: 'true'
|
||||
spec:
|
||||
strategy:
|
||||
type: Rolling
|
||||
triggers:
|
||||
- type: ImageChange
|
||||
imageChangeParams:
|
||||
automatic: true
|
||||
containerNames:
|
||||
- nodejs-example
|
||||
from:
|
||||
kind: ImageStreamTag
|
||||
name: {{ print .Values.name ":latest" | quote }}
|
||||
- type: ConfigChange
|
||||
replicas: 1
|
||||
selector:
|
||||
name: {{ .Values.name | quote }}
|
||||
template:
|
||||
metadata:
|
||||
name: {{ .Values.name | quote }}
|
||||
labels:
|
||||
name: {{ .Values.name | quote }}
|
||||
spec:
|
||||
containers:
|
||||
- name: nodejs-example
|
||||
image: " "
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
timeoutSeconds: 3
|
||||
initialDelaySeconds: 3
|
||||
httpGet:
|
||||
path: "/"
|
||||
port: 8080
|
||||
livenessProbe:
|
||||
timeoutSeconds: 3
|
||||
initialDelaySeconds: 30
|
||||
httpGet:
|
||||
path: "/"
|
||||
port: 8080
|
||||
resources:
|
||||
limits:
|
||||
memory: {{ .Values.memory_limit | quote }}
|
|
@ -1,6 +0,0 @@
|
|||
kind: ImageStream
|
||||
apiVersion: image.openshift.io/v1
|
||||
metadata:
|
||||
name: {{ .Values.name | quote }}
|
||||
annotations:
|
||||
description: Keeps track of changes in the application image
|
|
@ -1,9 +0,0 @@
|
|||
kind: Route
|
||||
apiVersion: route.openshift.io/v1
|
||||
metadata:
|
||||
name: {{ .Values.name | quote }}
|
||||
spec:
|
||||
host: {{ .Values.application_domain | quote }}
|
||||
to:
|
||||
kind: Service
|
||||
name: {{ .Values.name | quote }}
|
|
@ -1,13 +0,0 @@
|
|||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: {{ .Values.name | quote }}
|
||||
annotations:
|
||||
description: Exposes and load balances the application pods
|
||||
spec:
|
||||
ports:
|
||||
- name: web
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
name: {{ .Values.name | quote }}
|
|
@ -1,20 +0,0 @@
|
|||
# Name: The name assigned to all of the frontend objects defined in this template.
|
||||
name: nodejs-example
|
||||
# Namespace: The OpenShift Namespace where the ImageStream resides.
|
||||
namespace: openshift
|
||||
# Memory Limit: Maximum amount of memory the container can use.
|
||||
memory_limit: 512Mi
|
||||
# Git Repository URL: The URL of the repository with your application source code.
|
||||
source_repository_url: https://github.com/sclorg/nodejs-ex.git
|
||||
# Git Reference: Set this to a branch name, tag or other ref of your repository if you are not using the default branch.
|
||||
source_repository_ref:
|
||||
# Context Directory: Set this to the relative path to your project if it is not in the root of your repository.
|
||||
context_dir:
|
||||
# Application Hostname: The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.
|
||||
application_domain:
|
||||
# GitHub Webhook Secret: Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.
|
||||
github_webhook_secret:
|
||||
# Generic Webhook Secret: A secret string used to configure the Generic webhook.
|
||||
generic_webhook_secret:
|
||||
# Custom NPM Mirror URL: The custom NPM mirror URL
|
||||
npm_mirror:
|
|
@ -5,10 +5,10 @@ To do this, run:
|
|||
|
||||
```bash
|
||||
# create the nodejs example as usual
|
||||
oc new-app https://github.com/sclorg/nodejs-ex
|
||||
oc new-app https://github.com/openshift/nodejs-ex
|
||||
|
||||
# now create the pipeline build controller from the openshift/pipeline
|
||||
# subdirectory
|
||||
oc new-app https://github.com/sclorg/nodejs-ex \
|
||||
oc new-app https://github.com/openshift/nodejs-ex \
|
||||
--context-dir=openshift/pipeline --name nodejs-ex-pipeline
|
||||
```
|
||||
|
|
|
@ -4,18 +4,17 @@
|
|||
"metadata": {
|
||||
"name": "nodejs-mongo-persistent",
|
||||
"annotations": {
|
||||
"openshift.io/display-name": "Node.js + MongoDB",
|
||||
"description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.",
|
||||
"openshift.io/display-name": "Node.js + MongoDB (Persistent)",
|
||||
"description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.",
|
||||
"tags": "quickstart,nodejs",
|
||||
"iconClass": "icon-nodejs",
|
||||
"openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration.",
|
||||
"openshift.io/provider-display-name": "Red Hat, Inc.",
|
||||
"openshift.io/documentation-url": "https://github.com/sclorg/nodejs-ex",
|
||||
"openshift.io/support-url": "https://access.redhat.com",
|
||||
"template.openshift.io/bindable": "false"
|
||||
"template.openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration.",
|
||||
"template.openshift.io/provider-display-name": "Red Hat, Inc.",
|
||||
"template.openshift.io/documentation-url": "https://github.com/openshift/nodejs-ex",
|
||||
"template.openshift.io/support-url": "https://access.redhat.com"
|
||||
}
|
||||
},
|
||||
"message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.",
|
||||
"message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.",
|
||||
"labels": {
|
||||
"template": "nodejs-mongo-persistent"
|
||||
},
|
||||
|
@ -85,8 +84,7 @@
|
|||
"metadata": {
|
||||
"name": "${NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to build the application",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to build the application"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -104,7 +102,7 @@
|
|||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"namespace": "${NAMESPACE}",
|
||||
"name": "nodejs:${NODEJS_VERSION}"
|
||||
"name": "nodejs:6"
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
|
@ -151,8 +149,7 @@
|
|||
"metadata": {
|
||||
"name": "${NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the application server",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to deploy the application server"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -239,7 +236,7 @@
|
|||
"timeoutSeconds": 3,
|
||||
"initialDelaySeconds": 3,
|
||||
"httpGet": {
|
||||
"path": "/",
|
||||
"path": "/pagecount",
|
||||
"port": 8080
|
||||
}
|
||||
},
|
||||
|
@ -247,7 +244,7 @@
|
|||
"timeoutSeconds": 3,
|
||||
"initialDelaySeconds": 30,
|
||||
"httpGet": {
|
||||
"path": "/",
|
||||
"path": "/pagecount",
|
||||
"port": 8080
|
||||
}
|
||||
},
|
||||
|
@ -307,8 +304,7 @@
|
|||
"metadata": {
|
||||
"name": "${DATABASE_SERVICE_NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the database",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to deploy the database"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -326,7 +322,7 @@
|
|||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"namespace": "${NAMESPACE}",
|
||||
"name": "mongodb:${MONGODB_VERSION}"
|
||||
"name": "mongodb:3.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -448,20 +444,6 @@
|
|||
"required": true,
|
||||
"value": "openshift"
|
||||
},
|
||||
{
|
||||
"name": "NODEJS_VERSION",
|
||||
"displayName": "Version of NodeJS Image",
|
||||
"description": "Version of NodeJS image to be used (6, 8, or latest).",
|
||||
"value": "8",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_VERSION",
|
||||
"displayName": "Version of MongoDB Image",
|
||||
"description": "Version of MongoDB image to be used (3.6 or latest).",
|
||||
"value": "3.6",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "MEMORY_LIMIT",
|
||||
"displayName": "Memory Limit",
|
||||
|
@ -488,7 +470,7 @@
|
|||
"displayName": "Git Repository URL",
|
||||
"description": "The URL of the repository with your application source code.",
|
||||
"required": true,
|
||||
"value": "https://github.com/sclorg/nodejs-ex.git"
|
||||
"value": "https://github.com/openshift/nodejs-ex.git"
|
||||
},
|
||||
{
|
||||
"name": "SOURCE_REPOSITORY_REF",
|
||||
|
@ -509,7 +491,7 @@
|
|||
{
|
||||
"name": "GITHUB_WEBHOOK_SECRET",
|
||||
"displayName": "GitHub Webhook Secret",
|
||||
"description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
|
||||
"description": "A secret string used to configure the GitHub webhook.",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{40}"
|
||||
},
|
||||
|
|
|
@ -5,20 +5,18 @@
|
|||
"name": "nodejs-mongodb-example",
|
||||
"annotations": {
|
||||
"openshift.io/display-name": "Node.js + MongoDB (Ephemeral)",
|
||||
"description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.",
|
||||
"description": "An example Node.js application with a MongoDB database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.",
|
||||
"tags": "quickstart,nodejs",
|
||||
"iconClass": "icon-nodejs",
|
||||
"openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration. The database is stored in non-persistent storage, so this configuration should be used for experimental purposes only.",
|
||||
"openshift.io/provider-display-name": "Red Hat, Inc.",
|
||||
"openshift.io/documentation-url": "https://github.com/sclorg/nodejs-ex",
|
||||
"openshift.io/support-url": "https://access.redhat.com",
|
||||
"template.openshift.io/bindable": "false"
|
||||
"template.openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration, application deployment configuration, and database deployment configuration. The database is stored in non-persistent storage, so this configuration should be used for experimental purposes only.",
|
||||
"template.openshift.io/provider-display-name": "Red Hat, Inc.",
|
||||
"template.openshift.io/documentation-url": "https://github.com/openshift/nodejs-ex",
|
||||
"template.openshift.io/support-url": "https://access.redhat.com"
|
||||
}
|
||||
},
|
||||
"message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.",
|
||||
"message": "The following service(s) have been created in your project: ${NAME}, ${DATABASE_SERVICE_NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.",
|
||||
"labels": {
|
||||
"template": "nodejs-mongodb-example",
|
||||
"app": "nodejs-mongodb-example"
|
||||
"template": "nodejs-mongodb-example"
|
||||
},
|
||||
"objects": [
|
||||
{
|
||||
|
@ -86,8 +84,7 @@
|
|||
"metadata": {
|
||||
"name": "${NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to build the application",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to build the application"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -105,7 +102,7 @@
|
|||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"namespace": "${NAMESPACE}",
|
||||
"name": "nodejs:${NODEJS_VERSION}"
|
||||
"name": "nodejs:6"
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
|
@ -152,8 +149,7 @@
|
|||
"metadata": {
|
||||
"name": "${NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the application server",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to deploy the application server"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -240,7 +236,7 @@
|
|||
"timeoutSeconds": 3,
|
||||
"initialDelaySeconds": 3,
|
||||
"httpGet": {
|
||||
"path": "/",
|
||||
"path": "/pagecount",
|
||||
"port": 8080
|
||||
}
|
||||
},
|
||||
|
@ -248,7 +244,7 @@
|
|||
"timeoutSeconds": 3,
|
||||
"initialDelaySeconds": 30,
|
||||
"httpGet": {
|
||||
"path": "/",
|
||||
"path": "/pagecount",
|
||||
"port": 8080
|
||||
}
|
||||
},
|
||||
|
@ -291,8 +287,7 @@
|
|||
"metadata": {
|
||||
"name": "${DATABASE_SERVICE_NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the database",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to deploy the database"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -310,7 +305,7 @@
|
|||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"namespace": "${NAMESPACE}",
|
||||
"name": "mongodb:${MONGODB_VERSION}"
|
||||
"name": "mongodb:3.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -432,20 +427,6 @@
|
|||
"required": true,
|
||||
"value": "openshift"
|
||||
},
|
||||
{
|
||||
"name": "NODEJS_VERSION",
|
||||
"displayName": "Version of NodeJS Image",
|
||||
"description": "Version of NodeJS image to be used (6, 8, or latest).",
|
||||
"value": "8",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_VERSION",
|
||||
"displayName": "Version of MongoDB Image",
|
||||
"description": "Version of MongoDB image to be used (3.6 or latest).",
|
||||
"value": "3.6",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "MEMORY_LIMIT",
|
||||
"displayName": "Memory Limit",
|
||||
|
@ -465,7 +446,7 @@
|
|||
"displayName": "Git Repository URL",
|
||||
"description": "The URL of the repository with your application source code.",
|
||||
"required": true,
|
||||
"value": "https://github.com/sclorg/nodejs-ex.git"
|
||||
"value": "https://github.com/openshift/nodejs-ex.git"
|
||||
},
|
||||
{
|
||||
"name": "SOURCE_REPOSITORY_REF",
|
||||
|
@ -486,7 +467,7 @@
|
|||
{
|
||||
"name": "GITHUB_WEBHOOK_SECRET",
|
||||
"displayName": "GitHub Webhook Secret",
|
||||
"description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
|
||||
"description": "A secret string used to configure the GitHub webhook.",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{40}"
|
||||
},
|
||||
|
|
|
@ -5,20 +5,18 @@
|
|||
"name": "nodejs-example",
|
||||
"annotations": {
|
||||
"openshift.io/display-name": "Node.js",
|
||||
"description": "An example Node.js application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.",
|
||||
"description": "An example Node.js application with no database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.",
|
||||
"tags": "quickstart,nodejs",
|
||||
"iconClass": "icon-nodejs",
|
||||
"openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration and application deployment configuration. It does not include a database.",
|
||||
"openshift.io/provider-display-name": "Red Hat, Inc.",
|
||||
"openshift.io/documentation-url": "https://github.com/sclorg/nodejs-ex",
|
||||
"openshift.io/support-url": "https://access.redhat.com",
|
||||
"template.openshift.io/bindable": "false"
|
||||
"template.openshift.io/long-description": "This template defines resources needed to develop a NodeJS application, including a build configuration and application deployment configuration. It does not include a database.",
|
||||
"template.openshift.io/provider-display-name": "Red Hat, Inc.",
|
||||
"template.openshift.io/documentation-url": "https://github.com/openshift/nodejs-ex",
|
||||
"template.openshift.io/support-url": "https://access.redhat.com"
|
||||
}
|
||||
},
|
||||
"message": "The following service(s) have been created in your project: ${NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nodejs-ex/blob/master/README.md.",
|
||||
"message": "The following service(s) have been created in your project: ${NAME}.\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/openshift/nodejs-ex/blob/master/README.md.",
|
||||
"labels": {
|
||||
"template": "nodejs-example",
|
||||
"app": "nodejs-example"
|
||||
"template": "nodejs-example"
|
||||
},
|
||||
"objects": [
|
||||
{
|
||||
|
@ -73,8 +71,7 @@
|
|||
"metadata": {
|
||||
"name": "${NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to build the application",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to build the application"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -92,7 +89,7 @@
|
|||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"namespace": "${NAMESPACE}",
|
||||
"name": "nodejs:${NODEJS_VERSION}"
|
||||
"name": "nodejs:6"
|
||||
},
|
||||
"env": [
|
||||
{
|
||||
|
@ -139,8 +136,7 @@
|
|||
"metadata": {
|
||||
"name": "${NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the application server",
|
||||
"template.alpha.openshift.io/wait-for-ready": "true"
|
||||
"description": "Defines how to deploy the application server"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
|
@ -208,7 +204,12 @@
|
|||
}
|
||||
},
|
||||
"env": [
|
||||
]
|
||||
],
|
||||
"resources": {
|
||||
"limits": {
|
||||
"memory": "${MEMORY_LIMIT}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -231,13 +232,6 @@
|
|||
"required": true,
|
||||
"value": "openshift"
|
||||
},
|
||||
{
|
||||
"name": "NODEJS_VERSION",
|
||||
"displayName": "Version of NodeJS Image",
|
||||
"description": "Version of NodeJS image to be used (6, 8, or latest).",
|
||||
"value": "8",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "MEMORY_LIMIT",
|
||||
"displayName": "Memory Limit",
|
||||
|
@ -250,7 +244,7 @@
|
|||
"displayName": "Git Repository URL",
|
||||
"description": "The URL of the repository with your application source code.",
|
||||
"required": true,
|
||||
"value": "https://github.com/sclorg/nodejs-ex.git"
|
||||
"value": "https://github.com/openshift/nodejs-ex.git"
|
||||
},
|
||||
{
|
||||
"name": "SOURCE_REPOSITORY_REF",
|
||||
|
@ -271,7 +265,7 @@
|
|||
{
|
||||
"name": "GITHUB_WEBHOOK_SECRET",
|
||||
"displayName": "GitHub Webhook Secret",
|
||||
"description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
|
||||
"description": "A secret string used to configure the GitHub webhook.",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{40}"
|
||||
},
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/sclorg/nodejs-ex.git"
|
||||
"url": "http://github.com/openshift/nodejs-ex.git"
|
||||
},
|
||||
"author": "Steve Speicher <sspeiche@gmail.com>",
|
||||
"license": "CC-BY-1.0",
|
||||
"bugs": {
|
||||
"url": "http://github.com/sclorg/nodejs-ex/issues"
|
||||
"url": "http://github.com/openshift/nodejs-ex/issues"
|
||||
},
|
||||
"homepage": "http://github.com/sclorg/nodejs-ex"
|
||||
"homepage": "http://github.com/openshift/nodejs-ex"
|
||||
}
|
||||
|
|
38
server.js
38
server.js
|
@ -1,6 +1,8 @@
|
|||
// OpenShift sample Node application
|
||||
var express = require('express'),
|
||||
fs = require('fs'),
|
||||
app = express(),
|
||||
eps = require('ejs'),
|
||||
morgan = require('morgan');
|
||||
|
||||
Object.assign=require('object-assign')
|
||||
|
@ -13,31 +15,13 @@ var port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080,
|
|||
mongoURL = process.env.OPENSHIFT_MONGODB_DB_URL || process.env.MONGO_URL,
|
||||
mongoURLLabel = "";
|
||||
|
||||
if (mongoURL == null) {
|
||||
var mongoHost, mongoPort, mongoDatabase, mongoPassword, mongoUser;
|
||||
// If using plane old env vars via service discovery
|
||||
if (process.env.DATABASE_SERVICE_NAME) {
|
||||
var mongoServiceName = process.env.DATABASE_SERVICE_NAME.toUpperCase();
|
||||
mongoHost = process.env[mongoServiceName + '_SERVICE_HOST'];
|
||||
mongoPort = process.env[mongoServiceName + '_SERVICE_PORT'];
|
||||
mongoDatabase = process.env[mongoServiceName + '_DATABASE'];
|
||||
mongoPassword = process.env[mongoServiceName + '_PASSWORD'];
|
||||
mongoUser = process.env[mongoServiceName + '_USER'];
|
||||
|
||||
// If using env vars from secret from service binding
|
||||
} else if (process.env.database_name) {
|
||||
mongoDatabase = process.env.database_name;
|
||||
mongoPassword = process.env.password;
|
||||
mongoUser = process.env.username;
|
||||
var mongoUriParts = process.env.uri && process.env.uri.split("//");
|
||||
if (mongoUriParts.length == 2) {
|
||||
mongoUriParts = mongoUriParts[1].split(":");
|
||||
if (mongoUriParts && mongoUriParts.length == 2) {
|
||||
mongoHost = mongoUriParts[0];
|
||||
mongoPort = mongoUriParts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mongoURL == null && process.env.DATABASE_SERVICE_NAME) {
|
||||
var mongoServiceName = process.env.DATABASE_SERVICE_NAME.toUpperCase(),
|
||||
mongoHost = process.env[mongoServiceName + '_SERVICE_HOST'],
|
||||
mongoPort = process.env[mongoServiceName + '_SERVICE_PORT'],
|
||||
mongoDatabase = process.env[mongoServiceName + '_DATABASE'],
|
||||
mongoPassword = process.env[mongoServiceName + '_PASSWORD']
|
||||
mongoUser = process.env[mongoServiceName + '_USER'];
|
||||
|
||||
if (mongoHost && mongoPort && mongoDatabase) {
|
||||
mongoURLLabel = mongoURL = 'mongodb://';
|
||||
|
@ -47,6 +31,7 @@ if (mongoURL == null) {
|
|||
// Provide UI label that excludes user id and pw
|
||||
mongoURLLabel += mongoHost + ':' + mongoPort + '/' + mongoDatabase;
|
||||
mongoURL += mongoHost + ':' + mongoPort + '/' + mongoDatabase;
|
||||
|
||||
}
|
||||
}
|
||||
var db = null,
|
||||
|
@ -84,9 +69,6 @@ app.get('/', function (req, res) {
|
|||
// Create a document with request IP and current time of request
|
||||
col.insert({ip: req.ip, date: Date.now()});
|
||||
col.count(function(err, count){
|
||||
if (err) {
|
||||
console.log('Error running count. Message:\n'+err);
|
||||
}
|
||||
res.render('index.html', { pageCountMessage : count, dbInfo: dbDetails });
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -224,11 +224,11 @@ pre {
|
|||
<section class='col-xs-12 col-sm-6 col-md-6'>
|
||||
<section>
|
||||
<h2>How to use this example application</h2>
|
||||
<p>For instructions on how to use this application with OpenShift, start by reading the <a href="http://docs.okd.io/latest/dev_guide/templates.html#using-the-quickstart-templates">Developer Guide</a>.</p>
|
||||
<p>For instructions on how to use this application with OpenShift, start by reading the <a href="http://docs.openshift.org/latest/dev_guide/templates.html#using-the-quickstart-templates">Developer Guide</a>.</p>
|
||||
|
||||
<h2>Deploying code changes</h2>
|
||||
<p>
|
||||
The source code for this application is available to be forked from the <a href="https://www.github.com/sclorg/nodejs-ex">OpenShift GitHub repository</a>.
|
||||
The source code for this application is available to be forked from the <a href="https://www.github.com/openshift/nodejs-ex">OpenShift GitHub repository</a>.
|
||||
You can configure a webhook in your repository to make OpenShift automatically start a build whenever you push your code:
|
||||
</p>
|
||||
|
||||
|
@ -239,8 +239,7 @@ pre {
|
|||
<li>Click the Configuration tab</li>
|
||||
<li>Click the "Copy to clipboard" icon to the right of the "GitHub webhook URL" field</li>
|
||||
<li>Navigate to your repository on GitHub and click on repository settings > webhooks > Add webhook</li>
|
||||
<li>Paste your webhook URL provided by OpenShift in the "Payload URL" field</li>
|
||||
<li>Change the "Content type" to 'application/json'</li>
|
||||
<li>Paste your webhook URL provided by OpenShift</li>
|
||||
<li>Leave the defaults for the remaining fields — that's it!</li>
|
||||
</ol>
|
||||
<p>After you save your webhook, if you refresh your settings page you can see the status of the ping that Github sent to OpenShift to verify it can reach the server.</p>
|
||||
|
@ -266,20 +265,20 @@ $ git push</pre>
|
|||
|
||||
<h2>Managing your application</h2>
|
||||
|
||||
<p>Documentation on how to manage your application from the Web Console or Command Line is available at the <a href="http://docs.okd.io/latest/dev_guide/overview.html">Developer Guide</a>.</p>
|
||||
<p>Documentation on how to manage your application from the Web Console or Command Line is available at the <a href="http://docs.openshift.org/latest/dev_guide/overview.html">Developer Guide</a>.</p>
|
||||
|
||||
<h3>Web Console</h3>
|
||||
<p>You can use the Web Console to view the state of your application components and launch new builds.</p>
|
||||
|
||||
<h3>Command Line</h3>
|
||||
<p>With the <a href="http://docs.okd.io/latest/cli_reference/overview.html">OpenShift command line interface</a> (CLI), you can create applications and manage projects from a terminal.</p>
|
||||
<p>With the <a href="http://docs.openshift.org/latest/cli_reference/overview.html">OpenShift command line interface</a> (CLI), you can create applications and manage projects from a terminal.</p>
|
||||
|
||||
<h2>Development Resources</h2>
|
||||
<ul>
|
||||
<li><a href="http://docs.okd.io/latest/welcome/index.html">OpenShift Documentation</a></li>
|
||||
<li><a href="http://docs.openshift.org/latest/welcome/index.html">OpenShift Documentation</a></li>
|
||||
<li><a href="https://github.com/openshift/origin">Openshift Origin GitHub</a></li>
|
||||
<li><a href="https://github.com/openshift/source-to-image">Source To Image GitHub</a></li>
|
||||
<li><a href="http://docs.okd.io/latest/using_images/s2i_images/nodejs.html">Getting Started with Node.js on OpenShift</a></li>
|
||||
<li><a href="http://docs.openshift.org/latest/using_images/s2i_images/nodejs.html">Getting Started with Node.js on OpenShift</a></li>
|
||||
<li><a href="http://stackoverflow.com/questions/tagged/openshift">Stack Overflow questions for OpenShift</a></li>
|
||||
<li><a href="http://git-scm.com/documentation">Git documentation</a></li>
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue