« Previous 1 2
Cloud Foundry realizes a service mesh
Crossroads
Using the Service Mesh
Once the Cloud Foundry service mesh has been installed successfully, the admin can create weighted routes. As mentioned before, the cf
command-line tool does not yet support all commands, so admins have to run the commands directly against the Cloud Controller API with the help of the widely used Curl [3].
To begin, you need to create a route, which names a URL and thus makes it known to the main component in Cloud Foundry routing: the CFAR Gorouter:
# cf create-route development mesh.apps.anynines.com -n testapp
Note that the route is connected to a space at this point in time, but not to an application as yet. Associating a route with an application – route mapping – involves a separate step. First, however, you must take care of some preparatory work because integration is not complete. To begin, you must determine the route's GUID, which can be found in the resources[metadata]
field (Listing 1, line 10).
Listing 1
Determining the Route GUID
01 $ cf curl /v2/routes?q=host:testapp 02 { 03 "total_results": 2, 04 "total_pages": 1, 05 "prev_url": null, 06 "next_url": null, 07 "resources": [ 08 { 09 "metadata": { 10 "guid": "83d60b98-5864-45c6-94ad-4d02f5f4216a", 11 "url": "/v2/routes/83d60b98-5864-45c6-94ad-4d02f5f4216a", 12 "created_at": "2019-11-09T10:40:04Z", 13 "updated_at": "2019-11-09T10:40:04Z" 14 }, 15 "entity": { 16 "host": "tired-duck-brash-civet", 17 "path": "", 18 "domain_guid": "fb6bd89f-2ed9-49d4-9ad1-97951a573135", 19 "space_guid": "d6cddaa6-0886-44b3-9590-16717d5cd3c2", 20 "service_instance_guid": null, 21 "port": null, 22 "domain_url": "/v2/shared_domains/fb6bd89f-2ed9-49d4-9ad1-97951a573135", 23 "space_url": "/v2/spaces/d6cddaa6-0886-44b3-9590-16717d5cd3c2", 24 "apps_url": "/v2/routes/83d60b98-5864-45c6-94ad-4d02f5f4216a/apps", 25 "route_mappings_url": "/v2/routes/83d60b98-5864-45c6-94ad-4d02f5f4216a/route_mappings" 26 } 27 } 28 ] 29 }
Creating a weighted route in the form of a route mapping also requires you to specify an application, which you reference through its GUID. The app GUID is easy to determine:
$ cf app testapp --guid a4238936-3f25-463b-4061-d3436e277be3
Now you can create the route mapping, which also includes weighting for the associated application (Listing 2). The weighting factor in this example is 2 , which means that this route weighting is twice that of a route with the default value 1 . The statistical distribution of the requests to the individual route mappings is calculated by simple averaging. The individual weighting factors of all mappings are divided by their sum, giving the relative distribution ratios. In the case of two routes with weightings of 1 and 2, the result is 1/3 to 2/3; 33 percent of the requests go to the first application and 66 percent to the second (Figure 2).
Listing 2
Route Mapping
$ curl /v3/route_mappings -X POST -d '{ "relationships": { "app": { "guid": "a4238936-3f25-463b-4061-d3436e277be3" }, "route": { "guid": "83d60b98-5864-45c6-94ad-4d02f5f4216a" } }, "weight": 2 }'
To complete the above example, you therefore need to create another application and route mapping with the steps presented here. More detailed information on creating and modifying weighted routes can be found in the Cloud Foundry documentation [4].
Conclusions
The introduction of the service mesh can be seen as the Cloud Foundry developers' response to increasing demand. Developers of microservice-based applications need tools such as weighted routes to meet modern product and software development requirements. Comparing the use cases that service mesh technologies such as Istio and Envoy enable in the context of Kubernetes, it is reasonable to assume that these will also follow in Cloud Foundry.
Weighted routing could be followed by support for the Circuit Breaker pattern, rate limiting, and outlier detection. When and how this will happen remains to be seen; CFAR may be adapted step by step. Alternatively, incubation projects from the Cloud Foundry Foundation such as Eirini [5] could facilitate adaptation if the existing CFAR container subsystem is replaced by a Kubernetes back end.
Infos
- Istio: https://istio.io
- Envoy: https://www.envoyproxy.io
- Curl: https://curl.haxx.se
- Cloud Foundry weighted routing: https://docs.cloudfoundry.org/devguide/weighted-routing.html
- Cloud Foundry Eirini: https://www.cloudfoundry.org/project-eirini
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.