diff --git a/README.md b/README.md index df84b07f..38efc573 100644 --- a/README.md +++ b/README.md @@ -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: @@ -37,19 +37,23 @@ 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 @@ -57,24 +61,14 @@ These steps assume your OpenShift deployment has the default set of ImageStreams 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 @@ -82,12 +76,18 @@ These steps assume your OpenShift deployment has the default set of ImageStreams 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. diff --git a/openshift/templates/rails-postgresql.json b/openshift/templates/rails-postgresql.json index ec7da77e..3b83d3f5 100644 --- a/openshift/templates/rails-postgresql.json +++ b/openshift/templates/rails-postgresql.json @@ -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" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "rails-frontend" + "name": "rails-postgresql-example" } } }, @@ -39,13 +39,13 @@ "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" } } }, @@ -53,7 +53,7 @@ "kind": "ImageStream", "apiVersion": "v1", "metadata": { - "name": "rails-example", + "name": "rails-postgresql-example", "annotations": { "description": "Keeps track of changes in the application image" } @@ -63,7 +63,7 @@ "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "rails-example", + "name": "rails-postgresql-example", "annotations": { "description": "Defines how to build the application" } @@ -90,7 +90,7 @@ "output": { "to": { "kind": "ImageStreamTag", - "name": "rails-example:latest" + "name": "rails-postgresql-example:latest" } }, "triggers": [ @@ -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" } @@ -125,7 +125,7 @@ "command": [ "./migrate-database.sh" ], - "containerName": "rails-example" + "containerName": "rails-postgresql-example" } } } @@ -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" } } }, @@ -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 @@ -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",