Skip to content

Instantly share code, notes, and snippets.

@shubhaat
Last active May 9, 2019 13:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shubhaat/c8d1b3de775345d833ac3b682f3c46b2 to your computer and use it in GitHub Desktop.
Save shubhaat/c8d1b3de775345d833ac3b682f3c46b2 to your computer and use it in GitHub Desktop.
Weighted Routing in PAS
Prerequisites
1. Check the "Enable Service Mesh" checkbox on the PAS 2.5 tile
2. Operators will have to configure the firewall, DNS and Load balancer settings to resolve the *.service-mesh.<app domain> to the IP of the
edge envoy.
3. Push a test app (app_v1) and map a route to it, this demo is using [Dora](https://github.com/cloudfoundry/cf-acceptance-tests/tree/master/assets/dora).
Preferably the test app can print out a version or an instance id. Dora has an endpoint that returns an instance id.
4. Push the test app as app_v2 with no route mapped to it initially
Steps for demo
1. curl the route mapped to the app_v1 with the `/id` or the version endpoint on your app to test which version of the app is being curled
2. Change the weight for v1 to 9 such that when you map a route to v2 with a weight of 1,. 90% of the traffic goes to v1. The CAPI v3 endpoints are [here](http://v3-apidocs.cloudfoundry.org/version/3.68.0/index.html#route-mappings)
cf curl /v3/route_mappings/$(echo "$(cf curl /v3/apps/$(cf app app-v1 --guid)/route_mappings | jq .resources[0].guid)" | tr -d '"') \
-X PATCH \
-d '{
"weight": 9
}'
3. Map route to v2
cf map-route app-v2 mesh.apps.sanpablo.cf-app.com --hostname dora
4. Increase weigth for v2 to send 75% of the traffic
cf curl /v3/route_mappings/$(echo "$(cf curl /v3/apps/$(cf app app-v2 --guid)/route_mappings | jq .resources[0].guid)" | tr -d '"') \
-X PATCH \
-d '{
"weight": 27
}'
5. Unmap v1 send 100% of the traffic to v2
cf unmap-route dora-v1 mesh.apps.sanpablo.cf-app.com --hostname dora
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment