Skip to content

Commit

Permalink
Merge pull request #18 from gabemontero/issue3358
Browse files Browse the repository at this point in the history
get names consistent; associated doc updates based on test walkthrough
  • Loading branch information
bparees committed Jul 1, 2015
2 parents 33112e2 + 323dd60 commit d0c4dd2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,44 @@ Development environment can help you debug problems in your application in the s
The Perl container is set up so that Apache will load .conf files located within the <code>cfg</code> directory of the application's root. This is useful if you are configuring your application with a database backend and would want to pass through your environment variables to mod_perl with <code>PerlPassEnv</code>.

###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). 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 [dancer-ex](https://github.com/openshift/dancer-ex)
2. Clone your repository to your development machine and cd to the repository directory
3. Add a Perl application from the provided template and specify the source url to be your forked repo

$ oc new-app openshift/templates/dancer.json -p SOURCE_REPOSITORY_URL=<your repository location>

4. 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 start-build dancer-example

5. Once the build is running, watch your build progress

$ oc build-logs dancer-example-1

5. Wait for frontend pods to start up (this can take a few minutes):
6. Wait for dancer-example pods to start up (this can take a few minutes):

$ oc get pods -w


Sample output:

NAME READY REASON RESTARTS AGE
dancer-example-1-build 1/1 Running 0 4m
dancer-frontend-1-deploy 1/1 Running 0 4s
dancer-frontend-1-votfl 0/1 Pending 0 1s
NAME READY REASON RESTARTS AGE
dancer-example-1-build 0/1 ExitCode:0 0 4m
dancer-frontend-1-votfl 0/1 Running 0 6s
dancer-frontend-1-deploy 0/1 ExitCode:0 0 14s
dancer-frontend-1-votfl 1/1 Running 0 12s
dancer-example-1-9d9vh 1/1 Running 0 41s
dancer-example-1-build 0/1 ExitCode:0 0 4m


6. Check the IP and port the frontend service is running on:
6. Check the IP and port the dancer-example service is running on:

$ oc get svc

Sample output:

NAME LABELS SELECTOR IP(S) PORT(S)
dancer-frontend template=dancer-mysql-example name=dancer-frontend 172.30.174.142 8080/TCP
dancer-example template=dancer-example name=dancer-example 172.30.225.109 8080/TCP

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

###Installation: With MySQL
Expand Down Expand Up @@ -103,7 +101,9 @@ To add REST and DB connectivity to this sample app, you can up date the applicat
#default->to_app;
start;

You will then need to rebuild the application.
It will also be necessary to update your application to talk to your database back-end. The inventory.pm file is configured to use DBI and $ENV in such a way that it will accept environment variables for your connection information that you pass to it. After creating a MySQL database service in your project, you can add the following environment variables to your deploymentConfig to ensure all your dancer-example pods have access to these environment variables. Note: the dancer-mysql.json template creates the DB service and environment variables for you.

You will then need to rebuild the application. This is done via either a `oc start-build` command, or through the web console, or a webhook trigger in github initiating a build after the code changes are pushed.

###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/).
32 changes: 16 additions & 16 deletions openshift/templates/dancer-mysql.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "dancer-frontend",
"name": "dancer-mysql-example",
"annotations": {
"description": "Exposes and load balances the application pods"
}
Expand All @@ -31,29 +31,29 @@
}
],
"selector": {
"name": "dancer-frontend"
"name": "dancer-mysql-example"
}
}
},
{
"kind": "Route",
"apiVersion": "v1",
"metadata": {
"name": "dancer-route"
"name": "dancer-mysql-example"
},
"spec": {
"host": "${APPLICATION_DOMAIN}",
"to": {
"kind": "Service",
"name": "dancer-frontend"
"name": "dancer-mysql-example"
}
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "dancer-example",
"name": "dancer-mysql-example",
"annotations": {
"description": "Keeps track of changes in the application image"
}
Expand All @@ -63,7 +63,7 @@
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "dancer-example",
"name": "dancer-mysql-example",
"annotations": {
"description": "Defines how to build the application"
}
Expand All @@ -90,7 +90,7 @@
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "dancer-example:latest"
"name": "dancer-mysql-example:latest"
}
},
"triggers": [
Expand All @@ -110,7 +110,7 @@
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "dancer-frontend",
"name": "dancer-mysql-example",
"annotations": {
"description": "Defines how to deploy the application server"
}
Expand All @@ -122,11 +122,11 @@
"imageChangeParams": {
"automatic": true,
"containerNames": [
"dancer-example"
"dancer-mysql-example"
],
"from": {
"kind": "ImageStreamTag",
"name": "dancer-example:latest"
"name": "dancer-mysql-example:latest"
}
}
},
Expand All @@ -136,20 +136,20 @@
],
"replicas": 1,
"selector": {
"name": "dancer-frontend"
"name": "dancer-mysql-example"
},
"template": {
"metadata": {
"name": "dancer-frontend",
"name": "dancer-mysql-example",
"labels": {
"name": "dancer-frontend"
"name": "dancer-mysql-example"
}
},
"spec": {
"containers": [
{
"name": "dancer-example",
"image": "dancer-example",
"name": "dancer-mysql-example",
"image": "dancer-mysql-example",
"ports": [
{
"containerPort": 8080
Expand Down Expand Up @@ -282,7 +282,7 @@
{
"name": "APPLICATION_DOMAIN",
"description": "The exposed hostname that will route to the Dancer service",
"value": "dancer-example.openshiftapps.com"
"value": "dancer-mysql-example.openshiftapps.com"
},
{
"name": "GITHUB_WEBHOOK_SECRET",
Expand Down
16 changes: 8 additions & 8 deletions openshift/templates/dancer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "dancer-frontend",
"name": "dancer-example",
"annotations": {
"description": "Exposes and load balances the application pods"
}
Expand All @@ -31,21 +31,21 @@
}
],
"selector": {
"name": "dancer-frontend"
"name": "dancer-example"
}
}
},
{
"kind": "Route",
"apiVersion": "v1",
"metadata": {
"name": "dancer-route"
"name": "dancer-example"
},
"spec": {
"host": "${APPLICATION_DOMAIN}",
"to": {
"kind": "Service",
"name": "dancer-frontend"
"name": "dancer-example"
}
}
},
Expand Down Expand Up @@ -110,7 +110,7 @@
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "dancer-frontend",
"name": "dancer-example",
"annotations": {
"description": "Defines how to deploy the application server"
}
Expand Down Expand Up @@ -139,13 +139,13 @@
],
"replicas": 1,
"selector": {
"name": "dancer-frontend"
"name": "dancer-example"
},
"template": {
"metadata": {
"name": "dancer-frontend",
"name": "dancer-example",
"labels": {
"name": "dancer-frontend"
"name": "dancer-example"
}
},
"spec": {
Expand Down
14 changes: 7 additions & 7 deletions views/default.tt
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ start;</pre>
Note: the dancer-mysql.json template creates the DB service and environment variables for you.

<pre>
oc env dc/dancer-frontend DATABASE_SERVICE_NAME=&lt;database service name&gt;
oc env dc/dancer-frontend &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_HOST=&lt;database service ip&gt;
oc env dc/dancer-frontend &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_PORT=&lt;database service port&gt;
oc env dc/dancer-frontend MYSQL_DATABASE=&lt;your created database&gt;
oc env dc/dancer-frontend MYSQL_USER=&lt;your database user&gt;
oc env dc/dancer-frontend MYSQL_PASSWORD=&lt;your database user's password&gt;
oc env dc/dancer-mysql-example DATABASE_SERVICE_NAME=&lt;database service name&gt;
oc env dc/dancer-mysql-example &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_HOST=&lt;database service ip&gt;
oc env dc/dancer-mysql-example &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_PORT=&lt;database service port&gt;
oc env dc/dancer-mysql-example MYSQL_DATABASE=&lt;your created database&gt;
oc env dc/dancer-mysql-example MYSQL_USER=&lt;your database user&gt;
oc env dc/dancer-mysql-example MYSQL_PASSWORD=&lt;your database user's password&gt;
</pre>
</p>
<p>
Expand All @@ -288,7 +288,7 @@ oc env dc/dancer-frontend MYSQL_PASSWORD=&lt;your database user's password&gt;
You will need to redeploy your application in order to pick up the new environment variables. You can force a deployment
by running:
<pre>
oc deploy dancer-frontend --latest
oc deploy dancer-mysql-example --latest
</pre>
</p>

Expand Down

0 comments on commit d0c4dd2

Please sign in to comment.