api: Google gRPC client library configuration. (#398)
In support of https://github.com/envoyproxy/envoy/issues/2200 and some Google internal needs, we are planning on adding support to Envoy to allow a configuration (or possibly build) driven decision on whether to using the existing Envoy in-built Grpc::AsyncClient or the Google C++ gRPC client library (https://grpc.io/grpc/cpp/index.html). To move in this direction, the idea is we have the xDS ApiConfigSources, rate limit service config and other filter configurations point at a GrpcService object. This can be configured to use an Envoy cluster, where Grpc::AsyncClient will orchestrate communication, or to contain the config needed to establish a channel in Google C++ gRPC client library. Signed-off-by: Harvey Tuch <htuch@google.com>pull/403/head
parent
7901f02031
commit
b796da4964
19 changed files with 287 additions and 94 deletions
@ -0,0 +1,79 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
|
||||||
|
package envoy.api.v2; |
||||||
|
|
||||||
|
import "api/grpc_service.proto"; |
||||||
|
|
||||||
|
import "google/protobuf/duration.proto"; |
||||||
|
|
||||||
|
import "validate/validate.proto"; |
||||||
|
import "gogoproto/gogo.proto"; |
||||||
|
|
||||||
|
// [#protodoc-title: Configuration sources] |
||||||
|
|
||||||
|
// API configuration source. This identifies the API type and cluster that Envoy |
||||||
|
// will use to fetch an xDS API. |
||||||
|
message ApiConfigSource { |
||||||
|
// APIs may be fetched via either REST or gRPC. |
||||||
|
enum ApiType { |
||||||
|
// REST-JSON legacy corresponds to the v1 API. |
||||||
|
REST_LEGACY = 0; |
||||||
|
// REST-JSON v2 API. The `canonical JSON encoding |
||||||
|
// <https://developers.google.com/protocol-buffers/docs/proto3#json>`_ for |
||||||
|
// the v2 protos is used. |
||||||
|
REST = 1; |
||||||
|
// gRPC v2 API. |
||||||
|
GRPC = 2; |
||||||
|
} |
||||||
|
ApiType api_type = 1 [(validate.rules).enum.defined_only = true]; |
||||||
|
// Multiple cluster names may be provided for REST_LEGACY/REST. If > 1 |
||||||
|
// cluster is defined, clusters will be cycled through if any kind of failure |
||||||
|
// occurs. |
||||||
|
// |
||||||
|
// .. note:: |
||||||
|
// |
||||||
|
// The cluster with name ``cluster_name`` must be statically defined and its |
||||||
|
// type must not be ``EDS``. |
||||||
|
repeated string cluster_names = 2; |
||||||
|
|
||||||
|
// Multiple gRPC services be provided for GRPC. If > 1 cluster is defined, |
||||||
|
// services will be cycled through if any kind of failure occurs. |
||||||
|
// |
||||||
|
// .. note:: |
||||||
|
// |
||||||
|
// If a gRPC service points to a ``cluster_name``, it must be statically |
||||||
|
// defined and its type must not be ``EDS``. |
||||||
|
repeated GrpcService grpc_services = 4; |
||||||
|
|
||||||
|
// For REST APIs, the delay between successive polls. |
||||||
|
google.protobuf.Duration refresh_delay = 3 [(gogoproto.stdduration) = true]; |
||||||
|
} |
||||||
|
|
||||||
|
// Aggregated Discovery Service (ADS) options. This is currently empty, but when |
||||||
|
// set in :ref:`ConfigSource <envoy_api_msg_ConfigSource>` can be used to |
||||||
|
// specify that ADS is to be used. |
||||||
|
message AggregatedConfigSource { |
||||||
|
} |
||||||
|
|
||||||
|
// Configuration for :ref:`listeners <config_listeners>`, :ref:`clusters |
||||||
|
// <config_cluster_manager_cluster>`, :ref:`routes |
||||||
|
// <config_http_conn_man_route_table>`, :ref:`endpoints |
||||||
|
// <arch_overview_service_discovery>` etc. may either be sourced from the |
||||||
|
// filesystem or from an xDS API source. Filesystem configs are watched with |
||||||
|
// inotify for updates. |
||||||
|
message ConfigSource { |
||||||
|
oneof config_source_specifier { |
||||||
|
option (validate.required) = true; |
||||||
|
// Path on the filesystem to source and watch for configuration updates. |
||||||
|
// |
||||||
|
// .. note:: |
||||||
|
// |
||||||
|
// The path to the source must exist at config load time. |
||||||
|
string path = 1; |
||||||
|
// API configuration source. |
||||||
|
ApiConfigSource api_config_source = 2; |
||||||
|
// When set, ADS will be used to fetch resources. The ADS API configuration |
||||||
|
// source in the bootstrap configuration is used. |
||||||
|
AggregatedConfigSource ads = 3; |
||||||
|
} |
||||||
|
} |
@ -1,19 +0,0 @@ |
|||||||
syntax = "proto3"; |
|
||||||
|
|
||||||
package envoy.api.v2; |
|
||||||
|
|
||||||
import "google/protobuf/duration.proto"; |
|
||||||
|
|
||||||
import "validate/validate.proto"; |
|
||||||
|
|
||||||
// [#not-implemented-hide:] |
|
||||||
// GrpcCluster is used to expose generic gRPC cluster configuration that may |
|
||||||
// be used by filters to interface with a gRPC service. |
|
||||||
message GrpcCluster { |
|
||||||
// The name of the upstream gRPC cluster. |
|
||||||
string cluster_name = 1 [(validate.rules).string.min_bytes = 1]; |
|
||||||
|
|
||||||
// The timeout for the gRPC request. This is the timeout for a specific |
|
||||||
// request. |
|
||||||
google.protobuf.Duration timeout = 2; |
|
||||||
} |
|
@ -0,0 +1,81 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
|
||||||
|
package envoy.api.v2; |
||||||
|
|
||||||
|
import "api/base.proto"; |
||||||
|
|
||||||
|
import "google/protobuf/duration.proto"; |
||||||
|
|
||||||
|
import "validate/validate.proto"; |
||||||
|
|
||||||
|
// [#protodoc-title: gRPC services] |
||||||
|
// [#proto-status: draft] |
||||||
|
|
||||||
|
// gRPC service configuration. This is used by :ref:`ApiConfigSource |
||||||
|
// <envoy_api_msg_ApiConfigSource>` and filter configurations. |
||||||
|
message GrpcService { |
||||||
|
message EnvoyGrpc { |
||||||
|
// The name of the upstream gRPC cluster. SSL credentials will be supplied |
||||||
|
// in the :ref:`Cluster <envoy_api_msg_Cluster>` :ref:`tls_context |
||||||
|
// <envoy_api_field_Cluster.tls_context>`. |
||||||
|
string cluster_name = 1 [(validate.rules).string.min_bytes = 1]; |
||||||
|
} |
||||||
|
|
||||||
|
message GoogleGrpc { |
||||||
|
// The target URI when using the `Google C++ gRPC client |
||||||
|
// <https://github.com/grpc/grpc>`_. SSL credentials will be supplied in |
||||||
|
// :ref:`credentials <envoy_api_field_GrpcService.credentials>`. |
||||||
|
string target_uri = 1 [(validate.rules).string.min_bytes = 1]; |
||||||
|
|
||||||
|
// See https://grpc.io/grpc/cpp/structgrpc_1_1_ssl_credentials_options.html. |
||||||
|
message SslCredentials { |
||||||
|
// PEM encoded server root certificates. |
||||||
|
DataSource root_certs = 1; |
||||||
|
|
||||||
|
// PEM encoded client private key. |
||||||
|
DataSource private_key = 2; |
||||||
|
|
||||||
|
// PEM encoded client certificate chain. |
||||||
|
DataSource cert_chain = 3; |
||||||
|
} |
||||||
|
SslCredentials ssl_credentials = 2; |
||||||
|
} |
||||||
|
|
||||||
|
oneof target_specifier { |
||||||
|
option (validate.required) = true; |
||||||
|
|
||||||
|
// Envoy's in-built gRPC client. |
||||||
|
// See the :ref:`gRPC services overview <arch_overview_grpc_services>` |
||||||
|
// documentation for discussion on gRPC client selection. |
||||||
|
EnvoyGrpc envoy_grpc = 1; |
||||||
|
|
||||||
|
// `Google C++ gRPC client <https://github.com/grpc/grpc>`_ |
||||||
|
// See the :ref:`gRPC services overview <arch_overview_grpc_services>` |
||||||
|
// documentation for discussion on gRPC client selection. |
||||||
|
GoogleGrpc google_grpc = 2; |
||||||
|
} |
||||||
|
|
||||||
|
// The timeout for the gRPC request. This is the timeout for a specific |
||||||
|
// request. |
||||||
|
google.protobuf.Duration timeout = 3; |
||||||
|
|
||||||
|
// gRPC credentials as described at |
||||||
|
// https://grpc.io/docs/guides/auth.html#credential-types. |
||||||
|
// |
||||||
|
// .. note:: |
||||||
|
// |
||||||
|
// Credentials are only currently implemented for the Google gRPC client. |
||||||
|
message Credentials { |
||||||
|
oneof credential_specifier { |
||||||
|
option (validate.required) = true; |
||||||
|
|
||||||
|
// OAuth2 access token, see |
||||||
|
// https://grpc.io/grpc/cpp/namespacegrpc.html#ad3a80da696ffdaea943f0f858d7a360d. |
||||||
|
string access_token = 1; |
||||||
|
// [#comment: TODO(htuch): other gRPC auth types, e.g. IAM credentials, JWT, etc.] |
||||||
|
} |
||||||
|
} |
||||||
|
// A set of credentials that will be composed to form the `channel credentials |
||||||
|
// <https://grpc.io/docs/guides/auth.html#credential-types>`_. |
||||||
|
repeated Credentials credentials = 4; |
||||||
|
} |
Loading…
Reference in new issue