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 all 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
84 changes: 63 additions & 21 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,63 +36,105 @@ 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-route"></a> Change Load Balancing Algorithm of an Existing Route

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.


```
cf curl /v3/routes/?hosts=MY-APP
cf update-route EXAMPLE.COM --host MY-HOST --option loadbalancing=round-robin
```

Where `MY-APP` is the host attribute of the route. The response lists the chosen `loadbalancing` algorithm setting:
Alternatively, it is also possible to update the per-route load balancing option via the `/v3/routes` API.

Run the `PATCH` request to the targeted API endpoint:

```
"options": {
"loadbalancing": "least-connection"
}
cf curl /v3/routes/GUID -X PATCH -H "Content-type: application/json" \
-d '{
"options": {
"loadbalancing": "round-robin"
}
}'
```

### <a id="lb-update-curl"></a> Change Load Balancing of an Existing App
Where `GUID` is the unique identifier for the route.

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

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`:
To create a route with a per-route `loadbalancing` option, you can use the cli command `create-route`.
For example:

1. Execute a `PATCH` request to the targeted API endpoint:
```
cf create-route EXAMPLE.COM --host MY-HOST --option loadbalancing=round-robin
```
Dariquest marked this conversation as resolved.
Show resolved Hide resolved

Alternatively, it is also possible to create a route with a per-route load balancing option via the `/v3/routes` API:

```
cf curl /v3/routes/GUID -X PATCH -H "Content-type: application/json" \
cf curl /v3/routes -X POST -H "Content-type: application/json" \
-d '{
"host": "MY-HOST",
"path": "MY-PATH",
...
"options": {
"loadbalancing": "round-robin"
}
}'
```

Where `GUID` is the unique identifier for the route.
### <a id="lb-map-route"></a> Map a Route to an Existing App with specific 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`.

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

```
cf curl /v3/routes/GUID
cf map-route MY-APP EXAMPLE.COM --hostname MY-HOST --option loadbalancing=round-robin
```

Dariquest marked this conversation as resolved.
Show resolved Hide resolved
Where `GUID` is the unique identifier for the route. The response lists the new `round-robin` setting:
<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 read 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": "round-robin"
}
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": "least-connection"}
```

To retrieve all the routes with the corresponding options in a space of an organization, you can use `routes` command.