diff --git a/README.md b/README.md index b55bbad70..23c3b3cf8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ These are some special considerations you may need to keep in mind when running Since the quickstarts are shared code, we had to take special consideration to ensure that security related configuration variable values are unique across applications. To accomplish this, we modified some of the configuration files. Namely we changed Security.salt and Security.cipherSeed values in the app/Config/core.php config file. Those values are now generated from the application template as CAKEPHP_SECURITY_SALT and CAKEPHP_SECURITY_CIPHER_SEED. Also the secret token is generated in the template as CAKEPHP_SECRET_TOKEN. From these values the session hashes are generated. Now instead of using the same default values, OpenShift can generate these values using the generate from logic defined within the instant application's template. ###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 [cakephp-ex](https://github.com/openshift/cakephp-ex) 2. Clone your repository to your development machine and cd to the repository directory @@ -23,40 +23,42 @@ These steps assume your OpenShift deployment has the default set of ImageStreams $ oc new-app openshift/templates/cakephp.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 cakephp-example + +5. Once the build is running, watch your build progress $ oc build-logs cakephp-example-1 -5. Wait for frontend pods to start up (this can take a few minutes): +6. Wait for cakephp-example pods to start up (this can take a few minutes): $ oc get pods -w Sample output: - NAME READY REASON RESTARTS AGE - cakephp-example-1-build 1/1 Running 0 4m - cakephp-frontend-1-deploy 1/1 Running 0 4s - cakephp-frontend-1-votfl 0/1 Pending 0 1s - NAME READY REASON RESTARTS AGE - cakephp-example-1-build 0/1 ExitCode:0 0 4m - cakephp-frontend-1-votfl 0/1 Running 0 6s - cakephp-frontend-1-deploy 0/1 ExitCode:0 0 14s - cakephp-frontend-1-votfl 1/1 Running 0 12s + NAME READY REASON RESTARTS AGE + cakephp-example-1-build 0/1 ExitCode:0 0 8m + cakephp-example-1-pytud 1/1 Running 0 2m -6. Check the IP and port the frontend service is running on: +7. Check the IP and port the cakephp-example service is running on: $ oc get svc Sample output: - NAME LABELS SELECTOR IP(S) PORT(S) - cakephp-frontend template=cakephp-mysql-example name=cakephp-frontend 172.30.174.142 8080/TCP + NAME LABELS SELECTOR IP(S) PORT(S) + cakephp-example template=cakephp-example name=cakephp-example 172.30.97.123 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 cakephp-example is 172.30.97.123 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). + ###Installation: With MySQL 1. Follow the steps for the Manual Installation above for all but step 3, instead use step 2 below. - Note: The output in steps 5-6 may also display information about your database. @@ -78,7 +80,9 @@ Since OpenShift V3 does not provide a git repository out of the box, you can con ###Enabling the Database example In order to access the example CakePHP home page, which contains application stats including database connectivity, you have to go into the app/Views/Layouts/ directory, remove the default.ctp and after that rename default.ctp.default into default.ctp`. -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 app/Config/database.php file used by CakePHP was set up in such a way that it will accept environment variables for your connection information that you pass to it. Once an administrator has created a MySQL database service for you to connect with you can add the following environment variables to your deploymentConfig to ensure all your cakephp-example pods have access to these environment variables. Note: the cakephp-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/app/View/Layouts/default.ctp b/app/View/Layouts/default.ctp index 88c0c03e2..dd1697391 100644 --- a/app/View/Layouts/default.ctp +++ b/app/View/Layouts/default.ctp @@ -261,12 +261,12 @@ $ git push Note: the cakephp-mysql.json template creates the DB service and environment variables for you.
-oc env dc/cakephp-frontend DATABASE_SERVICE_NAME=<database service name>
-oc env dc/cakephp-frontend <DATABASE_SERVICE_NAME>_SERVICE_HOST=<database service ip>
-oc env dc/cakephp-frontend <DATABASE_SERVICE_NAME>_SERVICE_PORT=<database service port>
-oc env dc/cakephp-frontend MYSQL_DATABASE=<your created database>
-oc env dc/cakephp-frontend MYSQL_USER=<your database user>
-oc env dc/cakephp-frontend MYSQL_PASSWORD=<your database user's password>
+oc env dc/cakephp-mysql-example DATABASE_SERVICE_NAME=<database service name>
+oc env dc/cakephp-mysql-example <DATABASE_SERVICE_NAME>_SERVICE_HOST=<database service ip>
+oc env dc/cakephp-mysql-example <DATABASE_SERVICE_NAME>_SERVICE_PORT=<database service port>
+oc env dc/cakephp-mysql-example MYSQL_DATABASE=<your created database>
+oc env dc/cakephp-mysql-example MYSQL_USER=<your database user>
+oc env dc/cakephp-mysql-example MYSQL_PASSWORD=<your database user's password>
 

@@ -278,7 +278,7 @@ oc env dc/cakephp-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 cakephp-frontend --latest
+oc deploy cakephp-mysql-example --latest
 

diff --git a/openshift/templates/cakephp-mysql.json b/openshift/templates/cakephp-mysql.json index e5699bce7..b722a05ae 100644 --- a/openshift/templates/cakephp-mysql.json +++ b/openshift/templates/cakephp-mysql.json @@ -17,7 +17,7 @@ "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "cakephp-frontend", + "name": "cakephp-mysql-example", "annotations": { "description": "Exposes and load balances the application pods" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "cakephp-frontend" + "name": "cakephp-mysql-example" } } }, @@ -39,13 +39,13 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "cakephp-route" + "name": "cakephp-mysql-example" }, "spec": { "host": "${APPLICATION_DOMAIN}", "to": { "kind": "Service", - "name": "cakephp-frontend" + "name": "cakephp-mysql-example" } } }, @@ -53,7 +53,7 @@ "kind": "ImageStream", "apiVersion": "v1", "metadata": { - "name": "cakephp-example", + "name": "cakephp-mysql-example", "annotations": { "description": "Keeps track of changes in the application image" } @@ -63,7 +63,7 @@ "kind": "BuildConfig", "apiVersion": "v1", "metadata": { - "name": "cakephp-example", + "name": "cakephp-mysql-example", "annotations": { "description": "Defines how to build the application" } @@ -90,7 +90,7 @@ "output": { "to": { "kind": "ImageStreamTag", - "name": "cakephp-example:latest" + "name": "cakephp-mysql-example:latest" } }, "triggers": [ @@ -110,7 +110,7 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "cakephp-frontend", + "name": "cakephp-mysql-example", "annotations": { "description": "Defines how to deploy the application server" } @@ -125,7 +125,7 @@ "command": [ "./migrate-database.sh" ], - "containerName": "cakephp-example" + "containerName": "cakephp-mysql-example" } } } @@ -136,11 +136,11 @@ "imageChangeParams": { "automatic": true, "containerNames": [ - "cakephp-example" + "cakephp-mysql-example" ], "from": { "kind": "ImageStreamTag", - "name": "cakephp-example:latest" + "name": "cakephp-mysql-example:latest" } } }, @@ -150,20 +150,20 @@ ], "replicas": 1, "selector": { - "name": "cakephp-frontend" + "name": "cakephp-mysql-example" }, "template": { "metadata": { - "name": "cakephp-frontend", + "name": "cakephp-mysql-example", "labels": { - "name": "cakephp-frontend" + "name": "cakephp-mysql-example" } }, "spec": { "containers": [ { - "name": "cakephp-example", - "image": "cakephp-example", + "name": "cakephp-mysql-example", + "image": "cakephp-mysql-example", "ports": [ { "containerPort": 8080 @@ -308,7 +308,7 @@ { "name": "APPLICATION_DOMAIN", "description": "The exposed hostname that will route to the CakePHP service", - "value": "cakephp-example.openshiftapps.com" + "value": "cakephp-mysql-example.openshiftapps.com" }, { "name": "GITHUB_WEBHOOK_SECRET", diff --git a/openshift/templates/cakephp.json b/openshift/templates/cakephp.json index 09521add4..532b9bd2b 100644 --- a/openshift/templates/cakephp.json +++ b/openshift/templates/cakephp.json @@ -17,7 +17,7 @@ "kind": "Service", "apiVersion": "v1", "metadata": { - "name": "cakephp-frontend", + "name": "cakephp-example", "annotations": { "description": "Exposes and load balances the application pods" } @@ -31,7 +31,7 @@ } ], "selector": { - "name": "cakephp-frontend" + "name": "cakephp-example" } } }, @@ -39,13 +39,13 @@ "kind": "Route", "apiVersion": "v1", "metadata": { - "name": "cakephp-route" + "name": "cakephp-example" }, "spec": { "host": "${APPLICATION_DOMAIN}", "to": { "kind": "Service", - "name": "cakephp-frontend" + "name": "cakephp-example" } } }, @@ -110,7 +110,7 @@ "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { - "name": "cakephp-frontend", + "name": "cakephp-example", "annotations": { "description": "Defines how to deploy the application server" } @@ -139,13 +139,13 @@ ], "replicas": 1, "selector": { - "name": "cakephp-frontend" + "name": "cakephp-example" }, "template": { "metadata": { - "name": "cakephp-frontend", + "name": "cakephp-example", "labels": { - "name": "cakephp-frontend" + "name": "cakephp-example" } }, "spec": {