Skip to content

Commit

Permalink
Merge pull request #10 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 1ee3fdd + 94d1c09 commit cb80161
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 49 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,50 @@ 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
3. Add a PHP application from the provided template and specify the source url to be your forked repo

$ oc new-app openshift/templates/cakephp.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 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.
Expand All @@ -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/).
14 changes: 7 additions & 7 deletions app/View/Layouts/default.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ $ git push</pre>
Note: the cakephp-mysql.json template creates the DB service and environment variables for you.

<pre>
oc env dc/cakephp-frontend DATABASE_SERVICE_NAME=&lt;database service name&gt;
oc env dc/cakephp-frontend &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_HOST=&lt;database service ip&gt;
oc env dc/cakephp-frontend &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_PORT=&lt;database service port&gt;
oc env dc/cakephp-frontend MYSQL_DATABASE=&lt;your created database&gt;
oc env dc/cakephp-frontend MYSQL_USER=&lt;your database user&gt;
oc env dc/cakephp-frontend MYSQL_PASSWORD=&lt;your database user's password&gt;
oc env dc/cakephp-mysql-example DATABASE_SERVICE_NAME=&lt;database service name&gt;
oc env dc/cakephp-mysql-example &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_HOST=&lt;database service ip&gt;
oc env dc/cakephp-mysql-example &lt;DATABASE_SERVICE_NAME&gt;_SERVICE_PORT=&lt;database service port&gt;
oc env dc/cakephp-mysql-example MYSQL_DATABASE=&lt;your created database&gt;
oc env dc/cakephp-mysql-example MYSQL_USER=&lt;your database user&gt;
oc env dc/cakephp-mysql-example MYSQL_PASSWORD=&lt;your database user's password&gt;
</pre>
</p>
<p>
Expand All @@ -278,7 +278,7 @@ oc env dc/cakephp-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 cakephp-frontend --latest
oc deploy cakephp-mysql-example --latest
</pre>
</p>

Expand Down
34 changes: 17 additions & 17 deletions openshift/templates/cakephp-mysql.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -31,29 +31,29 @@
}
],
"selector": {
"name": "cakephp-frontend"
"name": "cakephp-mysql-example"
}
}
},
{
"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"
}
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "cakephp-example",
"name": "cakephp-mysql-example",
"annotations": {
"description": "Keeps track of changes in the application image"
}
Expand All @@ -63,7 +63,7 @@
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "cakephp-example",
"name": "cakephp-mysql-example",
"annotations": {
"description": "Defines how to build the application"
}
Expand All @@ -90,7 +90,7 @@
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "cakephp-example:latest"
"name": "cakephp-mysql-example:latest"
}
},
"triggers": [
Expand All @@ -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"
}
Expand All @@ -125,7 +125,7 @@
"command": [
"./migrate-database.sh"
],
"containerName": "cakephp-example"
"containerName": "cakephp-mysql-example"
}
}
}
Expand All @@ -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"
}
}
},
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions openshift/templates/cakephp.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "cakephp-frontend",
"name": "cakephp-example",
"annotations": {
"description": "Exposes and load balances the application pods"
}
Expand All @@ -31,21 +31,21 @@
}
],
"selector": {
"name": "cakephp-frontend"
"name": "cakephp-example"
}
}
},
{
"kind": "Route",
"apiVersion": "v1",
"metadata": {
"name": "cakephp-route"
"name": "cakephp-example"
},
"spec": {
"host": "${APPLICATION_DOMAIN}",
"to": {
"kind": "Service",
"name": "cakephp-frontend"
"name": "cakephp-example"
}
}
},
Expand Down Expand Up @@ -110,7 +110,7 @@
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "cakephp-frontend",
"name": "cakephp-example",
"annotations": {
"description": "Defines how to deploy the application server"
}
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit cb80161

Please sign in to comment.