Compare commits

...
Sign in to create a new pull request.

49 commits

Author SHA1 Message Date
Honza Horak
e59fe7571f
Merge pull request #206 from liangxia/okd
Update url to reflect OKD rebranding for nodejs-ex
2018-10-16 15:45:10 +02:00
liangxia
38584bb52a Update url to reflect OKD rebranding 2018-10-16 20:49:41 +08:00
Honza Horak
905416d88f
Merge pull request #204 from jeffdyoung/ppc64le
add example templates for ppc64le imagestreams
2018-09-25 07:47:27 +02:00
Honza Horak
f9a97276a0
Merge pull request #199 from sspeiche/binding-update
Add support for binding style env vars
2018-09-19 08:22:06 +02:00
root
e56c06e04a Edit templates to only include imagestreams that support both x86 and ppc64le 2018-09-18 10:53:06 -04:00
sspeiche
5f15c1edb0 Add support for binding style env vars 2018-08-19 11:12:02 -04:00
Ben Parees
b078bcff2f
Merge pull request #195 from rubenhulzebos/patch-1
Update index.html
2018-08-03 09:39:42 -04:00
rubenhulzebos
58e352aa69
Update index.html
Added Github webhook settings description.
2018-08-02 09:00:41 +02:00
Honza Horak
e79929f0b6
Merge pull request #191 from adambkaplan/sclorg-rename
Rename github org references to sclorg
2018-07-24 18:24:51 +02:00
Adam Kaplan
9b0e5f1539 Rename github org references to sclorg
Addresses openshift/origin##19998
2018-07-24 11:32:08 -04:00
Ben Parees
24e7e684ac
Merge pull request #187 from Gl4di4torRr/master
remove unnecessary $ from documentation
2018-06-26 08:44:42 -04:00
Gl4di4torRr
0cb2d44935 remove unnecessary $ from documentation 2018-06-26 07:20:30 -04:00
Honza Horak
a2aa814098
Merge pull request #178 from wozniakjan/issue/origin_19379/generalization_of_probes
mongodb openshift template: generalize probes
2018-05-04 09:16:28 +02:00
Jan Wozniak
003d0ac8d6 mongodb openshift template: generalize probes
fixes: https://github.com/openshift/origin/issues/19379
2018-05-02 12:17:13 +02:00
Honza Horak
8d138f94d7
Merge pull request #177 from bparees/parameterize
parameterize imagestreamtag refs in templates
2018-04-30 12:00:39 +02:00
Ben Parees
d416548286 parameterize imagestreamtag refs in templates 2018-04-26 13:59:59 -04:00
Ben Parees
93fc25fd35
Merge pull request #170 from dharmit/add-minishift-to-readme
Add documentation about using minishift
2018-03-06 13:34:31 -05:00
Dharmit Shah
dd9d5afa3b Add documentation about using minishif 2018-03-06 23:55:13 +05:30
Ben Parees
ef1b71a300
Merge pull request #160 from aliok/patch-1
Fix invalid JSON in template: nodejs.json
2018-01-12 10:16:26 -05:00
Ali Ok
e8d39a4936
Fix invalid JSON in template: nodejs.json
Got rid of a duplicate key
<done over Github UI>
2018-01-12 13:35:25 +03:00
Ben Parees
5faaac6933
Merge pull request #159 from sclorg/fix-template
Remove ' (Persistent)'
2018-01-05 17:19:04 -05:00
Pavel Valena
e79d273ea5 Remove ' (Persistent)'
https://github.com/openshift/origin/pull/17922#pullrequestreview-86940496
2018-01-05 22:39:15 +01:00
Ben Parees
debf979e0d
Merge pull request #156 from jim-minter/issue17649
add debug if error happens in count()
2017-12-06 23:18:36 -05:00
Jim Minter
c8e18b759c add debug if error happens in count() 2017-12-06 18:59:42 -06:00
Ben Parees
d1af14dc9f
Merge pull request #149 from gabemontero/app-label
add template 'app' label
2017-11-09 11:13:37 -05:00
gabemontero
4759b1bf2d add template 'app' label 2017-11-09 11:10:12 -05:00
Ben Parees
e598bfbe1f
Merge pull request #148 from jim-minter/issue16726
remove expose annotations from quickstarts and add bindable: false
2017-11-07 21:13:16 +01:00
Jim Minter
b84f207d3d remove expose annotations from quickstarts and add bindable: false 2017-11-07 13:03:41 -06:00
Ben Parees
96e651f58a Merge pull request #143 from bparees/annotations
remove template prefix from tsb annotations
2017-10-19 14:56:53 +02:00
Ben Parees
8ac25c1e3c remove template prefix from tsb annotations 2017-10-19 14:52:59 +02:00
Ben Parees
b9ba509aff Merge pull request #138 from jim-minter/helmchart
add basic helm chart
2017-09-14 21:54:13 -04:00
Jim Minter
d6a27c221f add basic helm chart 2017-09-14 17:48:56 -05:00
Ben Parees
44abae3f81 Merge pull request #136 from mordicool/patch-2
Update server.js - remove fs module
2017-09-04 21:45:45 -04:00
Mordechai Weinberg
64c46cb6ee Update server.js
No need for fs module here
2017-09-03 21:44:36 +03:00
Ben Parees
253f8095a9 Merge pull request #135 from mordicool/patch-1
Update server.js
2017-09-03 00:10:56 -04:00
mordicool
08397daddd Update server.js 2017-09-02 21:37:58 +03:00
Ben Parees
eb75af97ef Merge pull request #132 from jim-minter/wait-completion-fixups
add missing template.alpha.openshift.io/wait-for-ready annotations to examples
2017-08-18 13:22:39 -04:00
Jim Minter
5647b2a31c add missing template.alpha.openshift.io/wait-for-ready annotations to examples 2017-08-18 12:15:45 -05:00
Ben Parees
7c814b0d2c Merge pull request #131 from jim-minter/trello135-completion-detection
add template completion detection
2017-08-16 14:19:01 -04:00
Jim Minter
5ffcf0a43c add template completion detection 2017-08-14 12:04:44 -05:00
Ben Parees
863b14eab0 Merge pull request #130 from coreydaley/adding_compatibility_section
Adding compatibility section
2017-08-04 11:23:15 -04:00
Corey Daley
324865499e
Adding compatibility section 2017-08-04 11:22:35 -04:00
Ben Parees
f12494cff0 Merge pull request #128 from coreydaley/bugzilla_1365656_github_webhook_description_update
Updating GITHUB_WEBHOOK_SECRET description
2017-06-25 23:27:32 -04:00
Corey Daley
1a31042c81
Updating GITHUB_WEBHOOK_SECRET description 2017-06-25 23:08:48 -04:00
Ben Parees
68b66caa93 Merge pull request #125 from jim-minter/trello133-tsb-bind
update templates to use template.openshift.io/expose-uri
2017-06-13 12:24:08 -04:00
Jim Minter
5d9081445f update templates to use template.openshift.io/expose-uri 2017-06-13 17:20:59 +01:00
Ben Parees
3d44de3ba8 Merge pull request #117 from openshift/revert-112-revert-111-nodejs6
re-enable nodejs:6 in templates
2017-05-23 15:54:29 -04:00
Ben Parees
9a913714c7 Revert "Revert "Changed templates to use nodejs:6"" 2017-05-23 15:53:51 -04:00
Ben Parees
95c092763d Merge pull request #112 from openshift/revert-111-nodejs6
Revert "Changed templates to use nodejs:6"
2017-04-29 12:12:55 -04:00
16 changed files with 334 additions and 87 deletions

View file

@ -1,4 +1,34 @@
Node.js sample app on OpenShift!
<!-- 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!
-----------------
This example will serve a welcome page and the current hit count as stored in a database.
@ -8,25 +38,30 @@ 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.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).
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.
#### 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.
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.
#### 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).
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).
#### Running an Ansible playbook
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.
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.
### Creating a project
@ -34,7 +69,7 @@ Outlined as the [Advanced Installation](https://docs.openshift.org/latest/instal
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:
@ -52,7 +87,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/openshift/nodejs-ex -l name=myapp
$ oc new-app https://github.com/sclorg/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.
@ -60,9 +95,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/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/sclorg/nodejs-ex) (fork if you like).
$ git clone https://github.com/openshift/nodejs-ex
$ git clone https://github.com/sclorg/nodejs-ex
Looking at the repo, you'll notice three files in the openshift/template directory:
@ -98,7 +133,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/openshift/nodejs-ex with openshift/nodejs:0.10
bc/nodejs-ex builds https://github.com/sclorg/nodejs-ex with openshift/nodejs:0.10
build #1 running for 7 seconds
deployment #1 waiting on image or update
@ -144,7 +179,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.
@ -158,7 +193,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/openshift/nodejs-ex with openshift/nodejs:0.10
bc/nodejs-ex builds https://github.com/sclorg/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.
@ -181,7 +216,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/openshift/nodejs-ex with openshift/nodejs:0.10
bc/nodejs-ex builds https://github.com/sclorg/nodejs-ex with openshift/nodejs:0.10
deployment #2 deployed about a minute ago - 1 pod
deployment #1 deployed 2 hours ago
@ -205,11 +240,14 @@ 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
## License
This repository is compatible with Node.js 4 and higher, excluding any alpha or beta versions.
### 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/).

9
helm/nodejs/Chart.yaml Executable file
View file

@ -0,0 +1,9 @@
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

View file

@ -0,0 +1,3 @@
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.

View file

@ -0,0 +1,38 @@
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

View file

@ -0,0 +1,49 @@
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 }}

View file

@ -0,0 +1,6 @@
kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
name: {{ .Values.name | quote }}
annotations:
description: Keeps track of changes in the application image

View file

@ -0,0 +1,9 @@
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 }}

View file

@ -0,0 +1,13 @@
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 }}

20
helm/nodejs/values.yaml Normal file
View file

@ -0,0 +1,20 @@
# 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:

View file

@ -5,10 +5,10 @@ To do this, run:
```bash
# create the nodejs example as usual
oc new-app https://github.com/openshift/nodejs-ex
oc new-app https://github.com/sclorg/nodejs-ex
# now create the pipeline build controller from the openshift/pipeline
# subdirectory
oc new-app https://github.com/openshift/nodejs-ex \
oc new-app https://github.com/sclorg/nodejs-ex \
--context-dir=openshift/pipeline --name nodejs-ex-pipeline
```

View file

@ -4,17 +4,18 @@
"metadata": {
"name": "nodejs-mongo-persistent",
"annotations": {
"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.",
"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.",
"tags": "quickstart,nodejs",
"iconClass": "icon-nodejs",
"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"
"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"
}
},
"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.",
"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.",
"labels": {
"template": "nodejs-mongo-persistent"
},
@ -84,7 +85,8 @@
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to build the application"
"description": "Defines how to build the application",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -102,7 +104,7 @@
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "nodejs:4"
"name": "nodejs:${NODEJS_VERSION}"
},
"env": [
{
@ -149,7 +151,8 @@
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server"
"description": "Defines how to deploy the application server",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -236,7 +239,7 @@
"timeoutSeconds": 3,
"initialDelaySeconds": 3,
"httpGet": {
"path": "/pagecount",
"path": "/",
"port": 8080
}
},
@ -244,7 +247,7 @@
"timeoutSeconds": 3,
"initialDelaySeconds": 30,
"httpGet": {
"path": "/pagecount",
"path": "/",
"port": 8080
}
},
@ -304,7 +307,8 @@
"metadata": {
"name": "${DATABASE_SERVICE_NAME}",
"annotations": {
"description": "Defines how to deploy the database"
"description": "Defines how to deploy the database",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -322,7 +326,7 @@
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "mongodb:3.2"
"name": "mongodb:${MONGODB_VERSION}"
}
}
},
@ -444,6 +448,20 @@
"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",
@ -470,7 +488,7 @@
"displayName": "Git Repository URL",
"description": "The URL of the repository with your application source code.",
"required": true,
"value": "https://github.com/openshift/nodejs-ex.git"
"value": "https://github.com/sclorg/nodejs-ex.git"
},
{
"name": "SOURCE_REPOSITORY_REF",
@ -491,7 +509,7 @@
{
"name": "GITHUB_WEBHOOK_SECRET",
"displayName": "GitHub Webhook Secret",
"description": "A secret string used to configure the GitHub webhook.",
"description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
"generate": "expression",
"from": "[a-zA-Z0-9]{40}"
},

View file

@ -5,18 +5,20 @@
"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/openshift/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/sclorg/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",
"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"
"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"
}
},
"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.",
"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.",
"labels": {
"template": "nodejs-mongodb-example"
"template": "nodejs-mongodb-example",
"app": "nodejs-mongodb-example"
},
"objects": [
{
@ -84,7 +86,8 @@
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to build the application"
"description": "Defines how to build the application",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -102,7 +105,7 @@
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "nodejs:4"
"name": "nodejs:${NODEJS_VERSION}"
},
"env": [
{
@ -149,7 +152,8 @@
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server"
"description": "Defines how to deploy the application server",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -236,7 +240,7 @@
"timeoutSeconds": 3,
"initialDelaySeconds": 3,
"httpGet": {
"path": "/pagecount",
"path": "/",
"port": 8080
}
},
@ -244,7 +248,7 @@
"timeoutSeconds": 3,
"initialDelaySeconds": 30,
"httpGet": {
"path": "/pagecount",
"path": "/",
"port": 8080
}
},
@ -287,7 +291,8 @@
"metadata": {
"name": "${DATABASE_SERVICE_NAME}",
"annotations": {
"description": "Defines how to deploy the database"
"description": "Defines how to deploy the database",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -305,7 +310,7 @@
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "mongodb:3.2"
"name": "mongodb:${MONGODB_VERSION}"
}
}
},
@ -427,6 +432,20 @@
"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",
@ -446,7 +465,7 @@
"displayName": "Git Repository URL",
"description": "The URL of the repository with your application source code.",
"required": true,
"value": "https://github.com/openshift/nodejs-ex.git"
"value": "https://github.com/sclorg/nodejs-ex.git"
},
{
"name": "SOURCE_REPOSITORY_REF",
@ -467,7 +486,7 @@
{
"name": "GITHUB_WEBHOOK_SECRET",
"displayName": "GitHub Webhook Secret",
"description": "A secret string used to configure the GitHub webhook.",
"description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
"generate": "expression",
"from": "[a-zA-Z0-9]{40}"
},

View file

@ -5,18 +5,20 @@
"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/openshift/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/sclorg/nodejs-ex/blob/master/README.md.",
"tags": "quickstart,nodejs",
"iconClass": "icon-nodejs",
"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"
"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"
}
},
"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.",
"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.",
"labels": {
"template": "nodejs-example"
"template": "nodejs-example",
"app": "nodejs-example"
},
"objects": [
{
@ -71,7 +73,8 @@
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to build the application"
"description": "Defines how to build the application",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -89,7 +92,7 @@
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "nodejs:4"
"name": "nodejs:${NODEJS_VERSION}"
},
"env": [
{
@ -136,7 +139,8 @@
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server"
"description": "Defines how to deploy the application server",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
@ -204,12 +208,7 @@
}
},
"env": [
],
"resources": {
"limits": {
"memory": "${MEMORY_LIMIT}"
}
}
]
}
]
}
@ -232,6 +231,13 @@
"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",
@ -244,7 +250,7 @@
"displayName": "Git Repository URL",
"description": "The URL of the repository with your application source code.",
"required": true,
"value": "https://github.com/openshift/nodejs-ex.git"
"value": "https://github.com/sclorg/nodejs-ex.git"
},
{
"name": "SOURCE_REPOSITORY_REF",
@ -265,7 +271,7 @@
{
"name": "GITHUB_WEBHOOK_SECRET",
"displayName": "GitHub Webhook Secret",
"description": "A secret string used to configure the GitHub webhook.",
"description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
"generate": "expression",
"from": "[a-zA-Z0-9]{40}"
},

View file

@ -23,12 +23,12 @@
},
"repository": {
"type": "git",
"url": "http://github.com/openshift/nodejs-ex.git"
"url": "http://github.com/sclorg/nodejs-ex.git"
},
"author": "Steve Speicher <sspeiche@gmail.com>",
"license": "CC-BY-1.0",
"bugs": {
"url": "http://github.com/openshift/nodejs-ex/issues"
"url": "http://github.com/sclorg/nodejs-ex/issues"
},
"homepage": "http://github.com/openshift/nodejs-ex"
"homepage": "http://github.com/sclorg/nodejs-ex"
}

View file

@ -1,8 +1,6 @@
// OpenShift sample Node application
var express = require('express'),
fs = require('fs'),
app = express(),
eps = require('ejs'),
morgan = require('morgan');
Object.assign=require('object-assign')
@ -15,13 +13,31 @@ 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 && 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 (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 (mongoHost && mongoPort && mongoDatabase) {
mongoURLLabel = mongoURL = 'mongodb://';
@ -31,7 +47,6 @@ if (mongoURL == null && process.env.DATABASE_SERVICE_NAME) {
// Provide UI label that excludes user id and pw
mongoURLLabel += mongoHost + ':' + mongoPort + '/' + mongoDatabase;
mongoURL += mongoHost + ':' + mongoPort + '/' + mongoDatabase;
}
}
var db = null,
@ -69,6 +84,9 @@ 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 {

View file

@ -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.openshift.org/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.okd.io/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/openshift/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/sclorg/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,7 +239,8 @@ 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 &gt; webhooks &gt; Add webhook</li>
<li>Paste your webhook URL provided by OpenShift</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>Leave the defaults for the remaining fields &mdash; 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>
@ -265,20 +266,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.openshift.org/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.okd.io/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.openshift.org/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.okd.io/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.openshift.org/latest/welcome/index.html">OpenShift Documentation</a></li>
<li><a href="http://docs.okd.io/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.openshift.org/latest/using_images/s2i_images/nodejs.html">Getting Started with Node.js on OpenShift</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://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>