diff --git a/README.md b/README.md index 4f577c4..a89bab9 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ 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 cfg 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 PerlPassEnv. ###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 @@ -35,11 +35,15 @@ These steps assume your OpenShift deployment has the default set of ImageStreams $ oc new-app openshift/templates/dancer.json -p SOURCE_REPOSITORY_URL= -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 @@ -47,26 +51,20 @@ These steps assume your OpenShift deployment has the default set of ImageStreams 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 @@ -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/). \ No newline at end of file diff --git a/openshift/templates/dancer-mysql.json b/openshift/templates/dancer-mysql.json index fc92a1d..b46abfb 100644 --- a/openshift/templates/dancer-mysql.json +++ b/openshift/templates/dancer-mysql.json @@ -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" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "dancer-frontend" + "name": "dancer-mysql-example" } } }, @@ -39,13 +39,13 @@ "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" } } }, @@ -53,7 +53,7 @@ "kind": "ImageStream", "apiVersion": "v1", "metadata": { - "name": "dancer-example", + "name": "dancer-mysql-example", "annotations": { "description": "Keeps track of changes in the application image" } @@ -63,7 +63,7 @@ "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "dancer-example", + "name": "dancer-mysql-example", "annotations": { "description": "Defines how to build the application" } @@ -90,7 +90,7 @@ "output": { "to": { "kind": "ImageStreamTag", - "name": "dancer-example:latest" + "name": "dancer-mysql-example:latest" } }, "triggers": [ @@ -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" } @@ -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" } } }, @@ -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 @@ -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", diff --git a/openshift/templates/dancer.json b/openshift/templates/dancer.json index 829f50b..6f49a7d 100644 --- a/openshift/templates/dancer.json +++ b/openshift/templates/dancer.json @@ -17,7 +17,7 @@ "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "dancer-frontend", + "name": "dancer-example", "annotations": { "description": "Exposes and load balances the application pods" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "dancer-frontend" + "name": "dancer-example" } } }, @@ -39,13 +39,13 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "dancer-route" + "name": "dancer-example" }, "spec": { "host": "${APPLICATION_DOMAIN}", "to": { "kind": "Service", - "name": "dancer-frontend" + "name": "dancer-example" } } }, @@ -110,7 +110,7 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "dancer-frontend", + "name": "dancer-example", "annotations": { "description": "Defines how to deploy the application server" } @@ -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": { diff --git a/views/default.tt b/views/default.tt index d42580b..0477fd8 100644 --- a/views/default.tt +++ b/views/default.tt @@ -271,12 +271,12 @@ start; Note: the dancer-mysql.json template creates the DB service and environment variables for you.
-oc env dc/dancer-frontend DATABASE_SERVICE_NAME=<database service name>
-oc env dc/dancer-frontend <DATABASE_SERVICE_NAME>_SERVICE_HOST=<database service ip>
-oc env dc/dancer-frontend <DATABASE_SERVICE_NAME>_SERVICE_PORT=<database service port>
-oc env dc/dancer-frontend MYSQL_DATABASE=<your created database>
-oc env dc/dancer-frontend MYSQL_USER=<your database user>
-oc env dc/dancer-frontend MYSQL_PASSWORD=<your database user's password>
+oc env dc/dancer-mysql-example DATABASE_SERVICE_NAME=<database service name>
+oc env dc/dancer-mysql-example <DATABASE_SERVICE_NAME>_SERVICE_HOST=<database service ip>
+oc env dc/dancer-mysql-example <DATABASE_SERVICE_NAME>_SERVICE_PORT=<database service port>
+oc env dc/dancer-mysql-example MYSQL_DATABASE=<your created database>
+oc env dc/dancer-mysql-example MYSQL_USER=<your database user>
+oc env dc/dancer-mysql-example MYSQL_PASSWORD=<your database user's password>
 

@@ -288,7 +288,7 @@ oc env dc/dancer-frontend MYSQL_PASSWORD=<your database user's password> You will need to redeploy your application in order to pick up the new environment variables. You can force a deployment by running:

-oc deploy dancer-frontend --latest
+oc deploy dancer-mysql-example --latest