diff --git a/README.md b/README.md index 8530bb1..da63eda 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -COTD: Cat of the Day +# Cat/City of the Day php web application using JQuery Mobile that publishes a list of ordered items. Each item has an image and trivia associated with it. @@ -28,7 +28,61 @@ An example entry is as follows: # AB Deployment Example -To experiment with an A/B deployment scenario, follow the instructions in the blog entry at: https://blog.emergile.com/2016/10/07/ab-deployments-made-easy-with-openshift/ +To demonstrate AB deployments try the following: + +## Setup Environment +Fork this Git repo +Visit https://www.openshift.org/vm/ to create an instance of OpenShift + +## Create Project +Visit the Console at https://10.2.2.2:8443/console/ using credentials user/user +Create a project called cotd with description "Cat of the Day" + + oc new-project cotd --display-name="City of the day" --description='City of the day' + +## Create A Application +Visit your Git repo and change the data/selector.php to point to "cats" +Create a php application called cotd1 and point it to this Git repo +Verify that the application using http://cotd1-cotd.apps.10.2.2.2.xip.io + + oc new-app openshift/php:5.6~https://github.com/eformat/cotd.git#master --name=master + +## Create B Application +Visit your Git repo and change the data/selector.php to point to "cities" +Create a php application called cotd2 and point it to this Git repo +Verify that the application using http://cotd2-cotd.apps.10.2.2.2.xip.io + + oc new-app openshift/php:5.6~https://github.com/eformat/cotd.git#feature --name=feature + +## Create AB Route Target +Switch to the Applications > Routes tab in the Console +Create a route ab pointing to http://ab-cotd.apps.10.2.2.2.xip.io + + oc expose service master --hostname=cotd.192.168.137.2.xip.io --name=cotd + +## Change route policy to round robin +By default the HA proxy router will configure your route for least connection. +To work correctly with weights, set an annotation so that round robin balancing is used + + oc annotate route/cotd haproxy.router.openshift.io/balance=roundrobin + +## Create AB Routing Rule +From a terminal window issue an $ oc login https://10.2.2.2:8443 with credentials user/user +Set the project to cotd using $ oc project cotd +Create a AB route using the web UI - broswe to cotd Route +RouteSplit traffic across multiple services +Verify the AB 50/50 setting in the cotd project + + oc set route-backends routes/cotd master=50 feature=50 + +You can also incrementally adjust from client + + oc set route-backends routes/cotd --adjust feature=+10% + +## Verify AB Behavior +Launch a a different browser and set cookies preferences to "never allow" +Open http://ab-cotd.apps.10.2.2.2.xip.io +Refresh and note changes between cats and cities versions # Running using Docker Toolbox diff --git a/data/cats/rank.php b/data/cats/rank.php index c4b864a..b65d490 100755 --- a/data/cats/rank.php +++ b/data/cats/rank.php @@ -9,15 +9,15 @@ $_SESSION['app'] = 'COTD'; // Change ranking order here -$_SESSION['ranks'] = array( +$_SESSION['ranks'] = array( 'adelaide', - 'canberra', 'melbourne', - 'auckland', 'sydney', 'brisbane', 'perth', 'hobart', + 'canberra', + 'auckland', 'wellington', 'christchurch' ); diff --git a/etc/parseCotdLogs.pl b/etc/parseCotdLogs.pl index 6c6499b..49f1ec0 100755 --- a/etc/parseCotdLogs.pl +++ b/etc/parseCotdLogs.pl @@ -12,13 +12,15 @@ sub usage { EOF } -my ($pod) = $ARGV[0]; -die usage unless ($pod); +die usage unless scalar (@ARGV) > 0; my $dump; -{ - local $/ = undef; - $dump = `oc logs $pod` + +foreach my $pod (@ARGV) { + { + local $/ = undef; + $dump .= `oc logs $pod` + } } my ($fav_by_client, $fav_by_city, $fav_city); @@ -38,6 +40,7 @@ sub usage { print "Favourite by city and client.ip " . Data::Dumper->Dump([$fav_by_city],['$x']); print "Favourite by city " . Data::Dumper->Dump([$fav_city],['$x']); + #$string = 'Top\ city\ is'; #while( $dump =~ m/] (.{0,35}$string.{0,30}),/gisx ) { # # print "Found $1\n";