-
Notifications
You must be signed in to change notification settings - Fork 5.4k
implement rds api #464
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
implement rds api #464
Changes from 5 commits
b3c48b3
6ad8955
c8ec260
d2f8aba
77b9d36
1765042
acf3a58
6063d35
133dc1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| .. _config_http_conn_man_rds: | ||
|
|
||
| Route discovery service | ||
| ======================= | ||
|
|
||
| The route discovery service (RDS) API is an optional API that Envoy will call to dynamically fetch | ||
| :ref:`route configurations <config_http_conn_man_route_table>`. A route configuration includes both | ||
| HTTP header modifications, virtual hosts, and the individual route entries contained within each | ||
| virtual host. Each :ref:`HTTP connection manager filter <config_http_conn_man>` can independently | ||
| fetch its own route configuration via the API. | ||
|
|
||
| .. code-block:: json | ||
|
|
||
| { | ||
| "cluster": "{...}", | ||
| "route_config_name": "...", | ||
| "refresh_delay_ms": "..." | ||
| } | ||
|
|
||
| cluster | ||
| *(required, string)* The name of an upstream :ref:`cluster <config_cluster_manager_cluster>` that | ||
| hosts the route discovery service. The cluster must run a REST service that implements the | ||
| :ref:`RDS HTTP API <config_http_conn_man_rds_api>`. | ||
|
|
||
| route_config_name | ||
| *(required, string)* The name of the route configuration. This name will be passed to the | ||
| :ref:`RDS HTTP API <config_http_conn_man_rds_api>`. This allows an Envoy configuration with | ||
| multiple HTTP listeners (and associated HTTP connection manager filters) to use different route | ||
| configurations. | ||
|
|
||
| refresh_delay_ms | ||
| *(optional, integer)* The delay, in milliseconds, between fetches to the RDS API. Envoy will add | ||
| an additional random jitter to the delay that is between zero and *refresh_delay_ms* | ||
| milliseconds. Thus the longest possible refresh delay is 2 \* *refresh_delay_ms*. Default | ||
| value is 30000ms (30 seconds). | ||
|
|
||
| .. _config_http_conn_man_rds_api: | ||
|
|
||
| REST API | ||
| -------- | ||
|
|
||
| .. http:get:: /v1/routes/(string: route_config_name)/(string: service_cluster)/(string: service_node) | ||
|
|
||
| Asks the discovery service to return the route configuration for a particular `route_config_name`, | ||
| `service_cluster`, and `service_node`. `route_config_name` corresponds to the RDS configuration | ||
| parameter above. `service_cluster` corresponds to the :option:`--service-cluster` CLI option. | ||
| `service_node` corresponds to the :option:`--service-node` CLI option. Responses are a single JSON | ||
| object that contains a route configuration as defined in the :ref:`route configuration documentation | ||
| <config_http_conn_man_route_table>`. | ||
|
|
||
| A new route configuration will be gracefully swapped in such that existing requests are not | ||
| affected. This means that when a request starts, it sees a consistent snapshot of the route | ||
| configuration that does not change for the duration of the request. Thus, if an update changes a | ||
| timeout for example, only new requests will use the updated timeout value. | ||
|
|
||
| As a performance optimization, Envoy hashes the route configuration it receives from the RDS API and | ||
| will only perform a full reload if the hash value changes. | ||
|
|
||
| .. attention:: | ||
|
|
||
| Route configurations that are loaded via RDS are *not* checked to see if referenced clusters are | ||
| known to the :ref:`cluster manager <config_cluster_manager>`. The RDS API has been designed to | ||
| work alongside the :ref:`CDS API <config_cluster_manager_cds>` such that Envoy assumes eventually | ||
| consistent updates. If a route references an unknown cluster a 404 response will be returned by | ||
| the router filter. | ||
|
|
||
| Statistics | ||
| ---------- | ||
|
|
||
| RDS has a statistics tree rooted at *http.<stat_prefix>.rds.* with the following statistics: | ||
|
|
||
| .. csv-table:: | ||
| :header: Name, Type, Description | ||
| :widths: 1, 1, 2 | ||
|
|
||
| config_reload, Counter, Total API fetches that resulted in a config reload due to a different config | ||
| update_attempt, Counter, Total API fetches attempted | ||
| update_success, Counter, Total API fetches completed successfully | ||
| update_failure, Counter, Total API fetches that failed (either network or schema errors) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ Client TLS authentication filter :ref:`architecture overview <arch_overview_ssl_ | |
| "config": { | ||
| "auth_api_cluster": "...", | ||
| "stat_prefix": "...", | ||
| "refresh_interval_ms": "...", | ||
| "refresh_delay_ms": "...", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized that CLIENT_SSL_NETWORK_FILTER_SCHEMA doesn't have
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| "ip_white_list": [] | ||
| } | ||
| } | ||
|
|
@@ -28,10 +28,10 @@ stat_prefix | |
| *(required, string)* The prefix to use when emitting :ref:`statistics | ||
| <config_network_filters_client_ssl_auth_stats>`. | ||
|
|
||
| refresh_interval_ms | ||
| refresh_delay_ms | ||
| *(optional, integer)* Time in milliseconds between principal refreshes from the authentication | ||
| service. Default is 60000 (60s). The actual fetch time will be this value plus a random jittered | ||
| value between 0-refresh_interval_ms milliseconds. | ||
| value between 0-refresh_delay_ms milliseconds. | ||
|
|
||
| ip_white_list | ||
| *(optional, array)* An optional list of IP address and subnet masks that should be white listed | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/router/router.h" | ||
|
|
||
| namespace Router { | ||
|
|
||
| /** | ||
| * A provider for constant route configurations. | ||
| */ | ||
| class RouteConfigProvider { | ||
| public: | ||
| virtual ~RouteConfigProvider() {} | ||
|
|
||
| /** | ||
| * @return Router::ConfigPtr a route configuration for use during a single request. The returned | ||
| * config may be different on a subsequent call, so a new config should be acquired for | ||
| * each request flow. | ||
| */ | ||
| virtual Router::ConfigPtr config() PURE; | ||
| }; | ||
|
|
||
| typedef std::unique_ptr<RouteConfigProvider> RouteConfigProviderPtr; | ||
|
|
||
| } // Router |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,23 @@ const std::string Json::Schema::CLIENT_SSL_NETWORK_FILTER_SCHEMA(R"EOF( | |
| } | ||
| )EOF"); | ||
|
|
||
| const std::string Json::Schema::RDS_CONFIGURATION_SCHEMA(R"EOF( | ||
| { | ||
| "$schema": "http://json-schema.org/schema#", | ||
| "properties" : { | ||
| "cluster" : {"type": "string"}, | ||
| "route_config_name" : {"type": "string"}, | ||
| "refresh_delay_ms" : { | ||
| "type" : "integer", | ||
| "minimum" : 0, | ||
| "exclusiveMinimum" : true | ||
| } | ||
| }, | ||
| "required" : ["cluster", "route_config_name"], | ||
| "additionalProperties" : false | ||
| } | ||
| )EOF"); | ||
|
|
||
| const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF( | ||
| { | ||
| "$schema": "http://json-schema.org/schema#", | ||
|
|
@@ -201,6 +218,7 @@ const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF( | |
| "enum" : ["http1", "http2", "auto"] | ||
| }, | ||
| "stat_prefix" : {"type" : "string"}, | ||
| "rds" : {"type": "object"}, | ||
| "route_config" : {"type": "object"}, | ||
| "filters" : { | ||
| "type" : "array", | ||
|
|
@@ -242,7 +260,7 @@ const std::string Json::Schema::HTTP_CONN_NETWORK_FILTER_SCHEMA(R"EOF( | |
| "use_remote_address" : {"type" : "boolean"}, | ||
| "generate_request_id" : {"type" : "boolean"} | ||
| }, | ||
| "required" : ["codec_type", "stat_prefix", "route_config", "filters"], | ||
| "required" : ["codec_type", "stat_prefix", "filters"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should keep route_config. At line 222, it only checks for an object, so empty will pass. And the documentation above makes it seem like it should always be there.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ccaraman if that line in the documentation is removed, it aligns well with the rest of the checks in rds_impl.cc. WDYT?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not required anymore. I'm fixing the docs. |
||
| "additionalProperties" : false | ||
| } | ||
| )EOF"); | ||
|
|
@@ -698,7 +716,7 @@ const std::string Json::Schema::CLUSTER_MANAGER_SCHEMA(R"EOF( | |
| "type" : "object", | ||
| "properties" : { | ||
| "cluster" : {"type" : "object"}, | ||
| "refresh_interval_ms" : { | ||
| "refresh_delay_ms" : { | ||
| "type" : "integer", | ||
| "minimum" : 0, | ||
| "exclusiveMinimum" : true | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asks the route dicovery service... People might get confused.