Files
Michele Mancioppi a363a2485b [WIP] Mongo init
2020-06-07 12:54:58 +02:00
..
2020-06-07 12:54:58 +02:00
2019-09-08 14:32:12 +02:00
2020-01-31 17:14:03 +01:00

RobotShop on PCF [WIP]

Requirements

The following tiles up and running in the PCF foundation:

Create an organization and a space

cf create-org stan
cf create-space -o stan robotshop

Ensure routes are available

The following routes must be available for use:

  • web.<domain>
  • ratings.<domain>
  • cart.<domain>
  • catalogue.<domain>
  • shipping.<domain>
  • user.<domain>
  • payment.<domain>
  • dispatch.<domain>

Set up the services

cf target -o stan -s robotshop

Build applications

Build the Java apps, from the repository root:

pushd shipping && ./mvnw clean package && popd

First app push

RobotShop relies on specific binding names between services and apps, so we first push the apps without creating instances (all instance counts in the manifest are 0).

From the root of the repo:

cf push -f CF/manifest.yml

Create the services

cf cs p.mysql db-small mysql-cities
cf cs p.mysql db-small mysql-ratings
cf cs mongodb-odb replica_set_small mongodb
cf cs p.redis cache-small redis
cf cs p.rabbitmq single-node-3.7 rabbitmq

Init MongoDB

cf bind-service mongo-init mongodb --binding-name catalogue_database
cf run-task mongo-init 'node init-db.js' --name "Init MongoDB"

Init MySQL databases

Ratings database

cf bind-service mysql-init mysql-ratings --binding-name ratings_database
cf run-task mysql-init 'node init-db.js init-ratings.sql ratings_database' --name "Init Ratings database"

Shipping database

This one is not automated yet, as the mysql-init task app chokes on the large SQL init file. Something that works is to:

  1. bosh ssh into the MySQL virtual machine
  2. Find out admin password from /var/vcap/jobs/mysql/config/mylogin.cnf
  3. Download the "cities" init sql file and gunzip it
  4. /var/vcap/packages/percona-server/bin/mysql -u admin -p<adminpwd> -P 3306 -D service_instance_db < <sql_file>

Bind the services

Now that we have both apps and services, we can bind the former to the latter:

cf bind-service mysql-init mysql-ratings --binding-name ratings_database
cf bind-service ratings mysql-ratings --binding-name ratings_database
cf bind-service catalogue mongodb --binding-name catalogue_database
cf bind-service cart redis --binding-name cart_cache
cf bind-service shipping mysql-cities --binding-name shipping_database
cf bind-service user redis --binding-name users_cache
cf bind-service user mongodb --binding-name users_database
cf bind-service payment rabbitmq --binding-name dispatch_queue
cf bind-service dispatch rabbitmq --binding-name dispatch_queue

Configure EUM

Create a website in Instana. Edit the web/static/eum.html file accordingly, specifically replacing the values of the reportingUrl and key ienums.

Push again the web application (or the entire manifest, whatever is easier for you):

cf push -f CF/manifest.yml

Spin up the containers

Note: Feel free to replace the value after -i with how many container of any one kind you want.

cf scale -i 1 web
cf scale -i 1 ratings
cf scale -i 1 cart
cf scale -i 1 catalogue
cf scale -i 1 shipping
cf scale -i 1 user
cf scale -i 1 payment
cf scale -i 1 dispatch