Skip to content

Commit

Permalink
Merge pull request #34 from gabemontero/issue3358
Browse files Browse the repository at this point in the history
move to consistent name; README corrections borrowed from other examp…
  • Loading branch information
bparees committed Jul 1, 2015
2 parents 92d3570 + 89122e0 commit 700259a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TLDR: OpenShift can generate and expose environment variables to your applicatio
###Development mode
When you develop your Rails application in OpenShift, you can also enable the 'development' environment by setting the RAILS_ENV environment variable for your deploymentConfiguration, using the `oc` client, like:

$ oc env dc/frontend RAILS_ENV=development
$ oc env dc/rails-postgresql-example RAILS_ENV=development


If you do so, OpenShift will run your application under 'development' mode. In development mode, your application will:
Expand All @@ -37,57 +37,57 @@ If you do so, OpenShift will run your application under 'development' mode. In d
Development environment can help you debug problems in your application in the same way as you do when developing on your local machine. However, we strongly advise you to not run your application in this mode in production.

###Installation:
These steps assume your OpenShift deployment has the default set of ImageStreams defined. Instructions for installing the default ImageStreams are available [here](http://docs.openshift.org/latest/admin_guide/install/first_steps.html)
These steps assume your OpenShift deployment has the default set of ImageStreams defined. Instructions for installing the default ImageStreams are available [here](http://docs.openshift.org/latest/admin_guide/install/first_steps.html). Instructions for installing the default ImageStreams are available [here](http://docs.openshift.org/latest/admin_guide/install/first_steps.html). If you are defining the set of ImageStreams now, remember to pass in the proper cluster-admin credentials and to create the ImageStreams in the 'openshift' namespace.

1. Fork a copy of [rails-ex](https://github.com/openshift/rails-ex)
2. Clone your repository to your development machine and cd to the repository directory
3. Add a Ruby application from the rails template:

$ oc new-app openshift/templates/rails-postgresql.json -p SOURCE_REPOSITORY_URL=https://github.com/yourusername/rails-ex
$ oc new-app openshift/templates/rails-postgresql.json -p SOURCE_REPOSITORY_URL=https://github.com/< yourusername >/rails-ex

4. Note that creating from a template will automatically start a new build. Watch your build progress:
4. Depending on the state of your system, and whether additional items need to be downloaded, it may take around a minute for your build to be started automatically. If you do not want to wait, run

$ oc build-logs rails-example-1
$ oc start-build rails-postgresql-example

5. Wait for frontend pods to start up (this can take a few minutes):
5. Once the build is running, watch your build progress

$ oc build-logs rails-postgresql-example-1

6. Wait for rails-postgresql-example pods to start up (this can take a few minutes):

$ oc get pods -w


Sample output:

NAME READY REASON RESTARTS AGE
rails-example-1-build 1/1 Running 0 2m
NAME READY REASON RESTARTS AGE
rails-frontend-1-deploy 0/1 Pending 0 0s
rails-frontend-1-deploy 0/1 Running 0 2s
rails-frontend-1-prehook 0/1 Pending 0 0s
rails-frontend-1-deploy 1/1 Running 0 3s
rails-example-1-build 0/1 ExitCode:0 0 2m
rails-frontend-1-prehook 0/1 Running 0 6s
rails-frontend-1-prehook 0/1 ExitCode:0 0 10s
rails-frontend-1-xlqrp 0/1 Pending 0 0s
rails-frontend-1-xlqrp 0/1 Running 0 1s
rails-frontend-1-xlqrp 1/1 Running 0 11s
rails-frontend-1-deploy 0/1 ExitCode:0 0 24s
rails-frontend-1-prehook 0/1 ExitCode:0 0 22s
postgresql-1-vk6ny 1/1 Running 0 4m
rails-postgresql-example-1-build 0/1 ExitCode:0 0 3m
rails-postgresql-example-1-deploy 1/1 Running 0 34s
rails-postgresql-example-1-prehook 0/1 ExitCode:0 0 32s



6. Check the IP and port the frontend service is running on:
7. Check the IP and port the rails-postgresql-example service is running on:

$ oc get svc


Sample output:

NAME LABELS SELECTOR IP(S) PORT(S)
rails-frontend template=rails-example name=rails-frontend 172.30.161.15 8080/TCP
postgresql template=rails-postgresql-example name=postgresql 172.30.197.40 5432/TCP
rails-postgresql-example template=rails-postgresql-example name=rails-postgresql-example 172.30.205.117 8080/TCP


In this case, the IP for frontend is 172.30.161.15 and it is on port 8080.
In this case, the IP for rails-postgresql-example rails-postgresql-example is 172.30.205.117 and it is on port 8080.
*Note*: you can also get this information from the web console.


###Debugging Unexpected Failures

Review some of the common tips and suggestions [here](https://github.com/openshift/origin/blob/master/docs/debugging-openshift.md).

###Adding Webhooks and Making Code Changes
Since OpenShift V3 does not provide a git repository out of the box, you can configure your github repository to make a webhook call whenever you push your code.

Expand Down
34 changes: 17 additions & 17 deletions openshift/templates/rails-postgresql.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "rails-frontend",
"name": "rails-postgresql-example",
"annotations": {
"description": "Exposes and load balances the application pods"
}
Expand All @@ -31,29 +31,29 @@
}
],
"selector": {
"name": "rails-frontend"
"name": "rails-postgresql-example"
}
}
},
{
"kind": "Route",
"apiVersion": "v1",
"metadata": {
"name": "rails-route"
"name": "rails-postgresql-example"
},
"spec": {
"host": "${APPLICATION_DOMAIN}",
"to": {
"kind": "Service",
"name": "rails-frontend"
"name": "rails-postgresql-example"
}
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "rails-example",
"name": "rails-postgresql-example",
"annotations": {
"description": "Keeps track of changes in the application image"
}
Expand All @@ -63,7 +63,7 @@
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "rails-example",
"name": "rails-postgresql-example",
"annotations": {
"description": "Defines how to build the application"
}
Expand All @@ -90,7 +90,7 @@
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "rails-example:latest"
"name": "rails-postgresql-example:latest"
}
},
"triggers": [
Expand All @@ -110,7 +110,7 @@
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "rails-frontend",
"name": "rails-postgresql-example",
"annotations": {
"description": "Defines how to deploy the application server"
}
Expand All @@ -125,7 +125,7 @@
"command": [
"./migrate-database.sh"
],
"containerName": "rails-example"
"containerName": "rails-postgresql-example"
}
}
}
Expand All @@ -136,11 +136,11 @@
"imageChangeParams": {
"automatic": true,
"containerNames": [
"rails-example"
"rails-postgresql-example"
],
"from": {
"kind": "ImageStreamTag",
"name": "rails-example:latest"
"name": "rails-postgresql-example:latest"
}
}
},
Expand All @@ -150,20 +150,20 @@
],
"replicas": 1,
"selector": {
"name": "rails-frontend"
"name": "rails-postgresql-example"
},
"template": {
"metadata": {
"name": "rails-frontend",
"name": "rails-postgresql-example",
"labels": {
"name": "rails-frontend"
"name": "rails-postgresql-example"
}
},
"spec": {
"containers": [
{
"name": "rails-example",
"image": "rails-example",
"name": "rails-postgresql-example",
"image": "rails-postgresql-example",
"ports": [
{
"containerPort": 8080
Expand Down Expand Up @@ -328,7 +328,7 @@
{
"name": "APPLICATION_DOMAIN",
"description": "The exposed hostname that will route to the Rails service",
"value": "rails-example.openshiftapps.com"
"value": "rails-postgresql-example.openshiftapps.com"
},
{
"name": "GITHUB_WEBHOOK_SECRET",
Expand Down

0 comments on commit 700259a

Please sign in to comment.