Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-route options via CF cli #543

Merged
merged 24 commits into from
Feb 6, 2025
Merged
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7922fda
Per-route options via CF cli
Dariquest Jan 31, 2025
d8dba25
Update custom-per-route-options.html.md.erb
Dariquest Jan 31, 2025
026a39d
Update custom-per-route-options.html.md.erb
Dariquest Jan 31, 2025
31b0e73
Merge branch 'master' into patch-1
Dariquest Feb 3, 2025
b1f33a5
Rename least-connections
Dariquest Feb 4, 2025
7b24f44
Fix indents + wording consistency (with doc set)
anita-flegg Feb 4, 2025
11b90ca
Merge branch 'master' into patch-1
Dariquest Feb 4, 2025
ea118bc
Update custom-per-route-options.html.md.erb
Dariquest Feb 5, 2025
6abfc03
Update custom-per-route-options.html.md.erb
Dariquest Feb 5, 2025
bbfe478
Update custom-per-route-options.html.md.erb
Dariquest Feb 5, 2025
516dcdb
Update custom-per-route-options.html.md.erb
Dariquest Feb 5, 2025
41954bc
Update custom-per-route-options.html.md.erb
Dariquest Feb 5, 2025
a595971
Update custom-per-route-options.html.md.erb
Dariquest Feb 5, 2025
b593ca8
Change Note to use note class
anita-flegg Feb 5, 2025
32d49f1
Rename host MY-APP to MY-HOST
Dariquest Feb 5, 2025
e57290d
Correct the chapter vars
Dariquest Feb 5, 2025
4226c08
Unification
Dariquest Feb 5, 2025
9180f00
Remove repeating route check sections
Dariquest Feb 5, 2025
907f00a
Chapter adjustments
Dariquest Feb 5, 2025
f711736
Last review round
Dariquest Feb 6, 2025
985c202
Add api way to create a route with a per-route option
Dariquest Feb 6, 2025
8645686
Tags correction
Dariquest Feb 6, 2025
c823864
word-level improvement
Dariquest Feb 6, 2025
a654620
add cf routes command doc
Dariquest Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 65 additions & 23 deletions custom-per-route-options.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Configuring per-route options
owner: CF for VMs Networking
---

By default, communication between Gorouter and backends is configured via general settings at the platform level.
By default, communication between Gorouter and backends is configured through the general settings at the platform level.

This topic describes how to specify per-route Gorouter options scoped at the application level.
This greater granularity lets developers tailor optimal routing behavior for applications' unique load profiles or other requirements.
Expand Down Expand Up @@ -36,41 +36,32 @@ To configure per-route load balancing for an application that has not yet been p
applications:
- name: MY-APP
routes:
- route: MY-APP.EXAMPLE.COM
- route: MY-HOST.EXAMPLE.COM
options:
loadbalancing: least-connection
```

Where `MY-APP` is the name of your app and `MY-APP.EXAMPLE.COM` is the route you want to map to your app.
Where `MY-APP` is the name of your app and `MY-HOST.EXAMPLE.COM` is the route you want to map to your app.

1. Push the app with the manifest:

```
cf push -f manifest.yml
```

1. To confirm the setting, query the `routes` API endpoint for the app's route:
### <a id="lb-update-curl"></a> Change Load Balancing of an Existing Route
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency:

Suggested change
### <a id="lb-update-curl"></a> Change Load Balancing of an Existing Route
### <a id="lb-update-route"></a> Update Load Balancing Algorithm of an Existing Route


```
cf curl /v3/routes/?hosts=MY-APP
```

Where `MY-APP` is the host attribute of the route. The response lists the chosen `loadbalancing` algorithm setting:
To change the per-route `loadbalancing` option of an existing route, you can use the cli command, `update-route`.

For example, to change an app route's algorithm from `least-connection` to `round-robin`, you can run the `update-route` command:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, to change an app route's algorithm from `least-connection` to `round-robin`, you can run the `update-route` command:
For example, to change an app route's algorithm to `round-robin`, you can run the `update-route` command:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to leave the explicit change description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the command is not referring to least-connections in any way. The command is exactly the same when setting round-robin from scratch. I think the additional information about least-connection can confuse the reader.


```
"options": {
"loadbalancing": "least-connection"
}
cf update-route EXAMPLE.COM --host MY-HOST --option loadbalancing=round-robin
```

### <a id="lb-update-curl"></a> Change Load Balancing of an Existing App

To change the per-route `loadbalancing` setting of an app that has already been pushed, `cf curl` the `/v3/routes` API.
For example, to change an app route's algorithm from `least-connection` to `round-robin`:

1. Execute a `PATCH` request to the targeted API endpoint:
Alternatively, it is also possible to `cf curl` the `/v3/routes` API.

1. Run the `PATCH` request to the targeted API endpoint:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Run the `PATCH` request to the targeted API endpoint:


```
cf curl /v3/routes/GUID -X PATCH -H "Content-type: application/json" \
Expand All @@ -83,16 +74,67 @@ For example, to change an app route's algorithm from `least-connection` to `roun

Where `GUID` is the unique identifier for the route.

1. To confirm the setting, query the `routes` API endpoint for the route:
1. To confirm the option, query the `routes` API endpoint for the route:

```
cf curl /v3/routes/GUID
```

Where `GUID` is the unique identifier for the route. The response lists the new `round-robin` setting:
Where `GUID` is the unique identifier for the route.

The response lists the new `round-robin` option:

```
"options": {
"loadbalancing": "round-robin"
}
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the doc for "confirm" from the update section.

### <a id="lb-create-route"></a> Creating a Route with a specified Load Balancing Algorithm

To create a route with a per-route `loadbalancing` option, you can use the cli command `create-route`.
For example:

```
cf create-route EXAMPLE.COM --host MY-HOST --option loadbalancing=round-robin
```

### <a id="lb-map-route"></a> Mapping a New Route to an Existing App with a specified Load Balancing Algorithm

To create and map a new route to an existing application with the per-route `loadbalancing` option, you can use the cli command `map-route`.

For example:

```
cf map-route MY-APP EXAMPLE.COM --hostname MY-HOST --option loadbalancing=round-robin
```

<p class="note">
The command <code>map-route</code> supports the <code>--option</code> flag only for new routes.
To update an existing route, the command <code>update-route</code> must be used as described before.</p>

### <a id="lb-retrieve-route-options"></a> Retrieve Route Options

To verify route options, you can query the route using the `route` command:

```
cf route EXAMPLE.COM --hostname MY-HOST
```

The response lists the chosen `loadbalancing` algorithm option, e.g. `least-connection`:

```
options: {loadbalancing=least-connection}
```

Alternatively, you can query the `routes` API endpoint for a route:

```
cf curl /v3/routes/?hosts=MY-HOST
```

Where `MY-HOST` is the host attribute of the route. The response lists the chosen `loadbalancing` algorithm option as well:

```
"options": {
"loadbalancing": "round-robin"
}
"options": {"loadbalancing": "least-connection"}
```