1// Copyright 2019 The gRPC Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// This file contains the xds protocol and its dependency. It can't be used by 16// the gRPC library; otherwise there can be duplicate definition problems if 17// users depend on both gRPC and Envoy. It can only be used by gRPC tests. 18// 19// TODO(juanlishen): This file is a hack to avoid a problem we're 20// currently having where we can't depend on a proto file in an external 21// repo due to bazel limitations. Once that's fixed, this should be 22// removed. Until this, it should be used in the gRPC tests only, or else it 23// will cause a conflict due to the same proto messages being defined in 24// multiple files in the same binary. 25 26syntax = "proto3"; 27 28package envoy.api.v2; 29 30import "google/protobuf/any.proto"; 31 32message UInt32Value { 33 // The uint32 value. 34 uint32 value = 1; 35} 36 37message Status { 38 // The status code, which should be an enum value of [google.rpc.Code][]. 39 int32 code = 1; 40 41 // A developer-facing error message, which should be in English. Any 42 // user-facing error message should be localized and sent in the 43 // [google.rpc.Status.details][] field, or localized by the client. 44 string message = 2; 45 46 // A list of messages that carry the error details. There is a common set of 47 // message types for APIs to use. 48 repeated google.protobuf.Any details = 3; 49} 50 51// `Struct` represents a structured data value, consisting of fields 52// which map to dynamically typed values. In some languages, `Struct` 53// might be supported by a native representation. For example, in 54// scripting languages like JS a struct is represented as an 55// object. The details of that representation are described together 56// with the proto support for the language. 57// 58// The JSON representation for `Struct` is JSON object. 59message Struct { 60 // Unordered map of dynamically typed values. 61 map<string, Value> fields = 1; 62} 63 64// `Value` represents a dynamically typed value which can be either 65// null, a number, a string, a boolean, a recursive struct value, or a 66// list of values. A producer of value is expected to set one of that 67// variants, absence of any variant indicates an error. 68// 69// The JSON representation for `Value` is JSON value. 70message Value { 71 // The kind of value. 72 oneof kind { 73 // Represents a null value. 74 NullValue null_value = 1; 75 // Represents a double value. 76 double number_value = 2; 77 // Represents a string value. 78 string string_value = 3; 79 // Represents a boolean value. 80 bool bool_value = 4; 81 // Represents a structured value. 82 Struct struct_value = 5; 83 // Represents a repeated `Value`. 84 ListValue list_value = 6; 85 } 86} 87 88// `NullValue` is a singleton enumeration to represent the null value for the 89// `Value` type union. 90// 91// The JSON representation for `NullValue` is JSON `null`. 92enum NullValue { 93 // Null value. 94 NULL_VALUE = 0; 95} 96 97// `ListValue` is a wrapper around a repeated field of values. 98// 99// The JSON representation for `ListValue` is JSON array. 100message ListValue { 101 // Repeated field of dynamically typed values. 102 repeated Value values = 1; 103} 104 105/////////////////////////////////////////////////////////////////////////////// 106 107// Identifies location of where either Envoy runs or where upstream hosts run. 108message Locality { 109 // Region this :ref:`zone <envoy_api_field_core.Locality.zone>` belongs to. 110 string region = 1; 111 112 // Defines the local service zone where Envoy is running. Though optional, it 113 // should be set if discovery service routing is used and the discovery 114 // service exposes :ref:`zone data <envoy_api_field_endpoint.LocalityLbEndpoints.locality>`, 115 // either in this message or via :option:`--service-zone`. The meaning of zone 116 // is context dependent, e.g. `Availability Zone (AZ) 117 // <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html>`_ 118 // on AWS, `Zone <https://cloud.google.com/compute/docs/regions-zones/>`_ on 119 // GCP, etc. 120 string zone = 2; 121 122 // When used for locality of upstream hosts, this field further splits zone 123 // into smaller chunks of sub-zones so they can be load balanced 124 // independently. 125 string sub_zone = 3; 126} 127 128// Identifies a specific Envoy instance. The node identifier is presented to the 129// management server, which may use this identifier to distinguish per Envoy 130// configuration for serving. 131message Node { 132 // An opaque node identifier for the Envoy node. This also provides the local 133 // service node name. It should be set if any of the following features are 134 // used: :ref:`statsd <arch_overview_statistics>`, :ref:`CDS 135 // <config_cluster_manager_cds>`, and :ref:`HTTP tracing 136 // <arch_overview_tracing>`, either in this message or via 137 // :option:`--service-node`. 138 string id = 1; 139 140 // Defines the local service cluster name where Envoy is running. Though 141 // optional, it should be set if any of the following features are used: 142 // :ref:`statsd <arch_overview_statistics>`, :ref:`health check cluster 143 // verification <envoy_api_field_core.HealthCheck.HttpHealthCheck.service_name>`, 144 // :ref:`runtime override directory <envoy_api_msg_config.bootstrap.v2.Runtime>`, 145 // :ref:`user agent addition 146 // <envoy_api_field_config.filter.network.http_connection_manager.v2.HttpConnectionManager.add_user_agent>`, 147 // :ref:`HTTP global rate limiting <config_http_filters_rate_limit>`, 148 // :ref:`CDS <config_cluster_manager_cds>`, and :ref:`HTTP tracing 149 // <arch_overview_tracing>`, either in this message or via 150 // :option:`--service-cluster`. 151 string cluster = 2; 152 153 // Opaque metadata extending the node identifier. Envoy will pass this 154 // directly to the management server. 155 Struct metadata = 3; 156 157 // Locality specifying where the Envoy instance is running. 158 Locality locality = 4; 159 160 // This is motivated by informing a management server during canary which 161 // version of Envoy is being tested in a heterogeneous fleet. This will be set 162 // by Envoy in management server RPCs. 163 string build_version = 5 [deprecated = true]; 164 165 // Free-form string that identifies the entity requesting config. 166 // E.g. "envoy" or "grpc" 167 string user_agent_name = 6; 168 169 oneof user_agent_version_type { 170 // Free-form string that identifies the version of the entity requesting config. 171 // E.g. "1.12.2" or "abcd1234", or "SpecialEnvoyBuild" 172 string user_agent_version = 7; 173 } 174 175 // Client feature support list. These are well known features described 176 // in the Envoy API repository for a given major version of an API. Client features 177 // use reverse DNS naming scheme, for example `com.acme.feature`. 178 // See :ref:`the list of features <client_features>` that xDS client may 179 // support. 180 repeated string client_features = 10; 181} 182 183/////////////////////////////////////////////////////////////////////////////// 184 185// A DiscoveryRequest requests a set of versioned resources of the same type for 186// a given Envoy node on some API. 187message DiscoveryRequest { 188 // The version_info provided in the request messages will be the version_info 189 // received with the most recent successfully processed response or empty on 190 // the first request. It is expected that no new request is sent after a 191 // response is received until the Envoy instance is ready to ACK/NACK the new 192 // configuration. ACK/NACK takes place by returning the new API config version 193 // as applied or the previous API config version respectively. Each type_url 194 // (see below) has an independent version associated with it. 195 string version_info = 1; 196 197 // The node making the request. 198 Node node = 2; 199 200 // List of resources to subscribe to, e.g. list of cluster names or a route 201 // configuration name. If this is empty, all resources for the API are 202 // returned. LDS/CDS expect empty resource_names, since this is global 203 // discovery for the Envoy instance. The LDS and CDS responses will then imply 204 // a number of resources that need to be fetched via EDS/RDS, which will be 205 // explicitly enumerated in resource_names. 206 repeated string resource_names = 3; 207 208 // Type of the resource that is being requested, e.g. 209 // "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment". This is implicit 210 // in requests made via singleton xDS APIs such as CDS, LDS, etc. but is 211 // required for ADS. 212 string type_url = 4; 213 214 // nonce corresponding to DiscoveryResponse being ACK/NACKed. See above 215 // discussion on version_info and the DiscoveryResponse nonce comment. This 216 // may be empty if no nonce is available, e.g. at startup or for non-stream 217 // xDS implementations. 218 string response_nonce = 5; 219 220 // This is populated when the previous :ref:`DiscoveryResponse <envoy_api_msg_DiscoveryResponse>` 221 // failed to update configuration. The *message* field in *error_details* provides the Envoy 222 // internal exception related to the failure. It is only intended for consumption during manual 223 // debugging, the string provided is not guaranteed to be stable across Envoy versions. 224 Status error_detail = 6; 225} 226 227message DiscoveryResponse { 228 // The version of the response data. 229 string version_info = 1; 230 231 // The response resources. These resources are typed and depend on the API being called. 232 repeated google.protobuf.Any resources = 2; 233 234 // [#not-implemented-hide:] 235 // Canary is used to support two Envoy command line flags: 236 // 237 // * --terminate-on-canary-transition-failure. When set, Envoy is able to 238 // terminate if it detects that configuration is stuck at canary. Consider 239 // this example sequence of updates: 240 // - Management server applies a canary config successfully. 241 // - Management server rolls back to a production config. 242 // - Envoy rejects the new production config. 243 // Since there is no sensible way to continue receiving configuration 244 // updates, Envoy will then terminate and apply production config from a 245 // clean slate. 246 // * --dry-run-canary. When set, a canary response will never be applied, only 247 // validated via a dry run. 248 bool canary = 3; 249 250 // Type URL for resources. This must be consistent with the type_url in the 251 // Any messages for resources if resources is non-empty. This effectively 252 // identifies the xDS API when muxing over ADS. 253 string type_url = 4; 254 255 // For gRPC based subscriptions, the nonce provides a way to explicitly ack a 256 // specific DiscoveryResponse in a following DiscoveryRequest. Additional 257 // messages may have been sent by Envoy to the management server for the 258 // previous version on the stream prior to this DiscoveryResponse, that were 259 // unprocessed at response send time. The nonce allows the management server 260 // to ignore any further DiscoveryRequests for the previous version until a 261 // DiscoveryRequest bearing the nonce. The nonce is optional and is not 262 // required for non-stream based xDS implementations. 263 string nonce = 5; 264} 265 266/////////////////////////////////////////////////////////////////////////////// 267 268message Pipe { 269 // Unix Domain Socket path. On Linux, paths starting with '@' will use the 270 // abstract namespace. The starting '@' is replaced by a null byte by Envoy. 271 // Paths starting with '@' will result in an error in environments other than 272 // Linux. 273 string path = 1; 274} 275 276message SocketAddress { 277 enum Protocol { 278 TCP = 0; 279 // [#not-implemented-hide:] 280 UDP = 1; 281 } 282 Protocol protocol = 1; 283 // The address for this socket. :ref:`Listeners <config_listeners>` will bind 284 // to the address. An empty address is not allowed. Specify ``0.0.0.0`` or ``::`` 285 // to bind to any address. [#comment:TODO(zuercher) reinstate when implemented: 286 // It is possible to distinguish a Listener address via the prefix/suffix matching 287 // in :ref:`FilterChainMatch <envoy_api_msg_listener.FilterChainMatch>`.] When used 288 // within an upstream :ref:`BindConfig <envoy_api_msg_core.BindConfig>`, the address 289 // controls the source address of outbound connections. For :ref:`clusters 290 // <envoy_api_msg_Cluster>`, the cluster type determines whether the 291 // address must be an IP (*STATIC* or *EDS* clusters) or a hostname resolved by DNS 292 // (*STRICT_DNS* or *LOGICAL_DNS* clusters). Address resolution can be customized 293 // via :ref:`resolver_name <envoy_api_field_core.SocketAddress.resolver_name>`. 294 string address = 2; 295 oneof port_specifier { 296 uint32 port_value = 3; 297 // This is only valid if :ref:`resolver_name 298 // <envoy_api_field_core.SocketAddress.resolver_name>` is specified below and the 299 // named resolver is capable of named port resolution. 300 string named_port = 4; 301 } 302 // The name of the resolver. This must have been registered with Envoy. If this is 303 // empty, a context dependent default applies. If address is a hostname this 304 // should be set for resolution other than DNS. If the address is a concrete 305 // IP address, no resolution will occur. 306 string resolver_name = 5; 307 308 // When binding to an IPv6 address above, this enables `IPv4 compatibity 309 // <https://tools.ietf.org/html/rfc3493#page-11>`_. Binding to ``::`` will 310 // allow both IPv4 and IPv6 connections, with peer IPv4 addresses mapped into 311 // IPv6 space as ``::FFFF:<IPv4-address>``. 312 bool ipv4_compat = 6; 313} 314 315// Addresses specify either a logical or physical address and port, which are 316// used to tell Envoy where to bind/listen, connect to upstream and find 317// management servers. 318message Address { 319 oneof address { 320 321 SocketAddress socket_address = 1; 322 Pipe pipe = 2; 323 } 324} 325 326/////////////////////////////////////////////////////////////////////////////// 327 328message Metadata { 329 // Key is the reverse DNS filter name, e.g. com.acme.widget. The envoy.* 330 // namespace is reserved for Envoy's built-in filters. 331 map<string, Struct> filter_metadata = 1; 332} 333 334/////////////////////////////////////////////////////////////////////////////// 335 336// Endpoint health status. 337enum HealthStatus { 338 // The health status is not known. This is interpreted by Envoy as *HEALTHY*. 339 UNKNOWN = 0; 340 341 // Healthy. 342 HEALTHY = 1; 343 344 // Unhealthy. 345 UNHEALTHY = 2; 346 347 // Connection draining in progress. E.g., 348 // `<https://aws.amazon.com/blogs/aws/elb-connection-draining-remove-instances-from-service-with-care/>`_ 349 // or 350 // `<https://cloud.google.com/compute/docs/load-balancing/enabling-connection-draining>`_. 351 // This is interpreted by Envoy as *UNHEALTHY*. 352 DRAINING = 3; 353 354 // Health check timed out. This is part of HDS and is interpreted by Envoy as 355 // *UNHEALTHY*. 356 TIMEOUT = 4; 357} 358 359/////////////////////////////////////////////////////////////////////////////// 360 361// Upstream host identifier. 362message Endpoint { 363 // The upstream host address. 364 // 365 // .. attention:: 366 // 367 // The form of host address depends on the given cluster type. For STATIC or EDS, 368 // it is expected to be a direct IP address (or something resolvable by the 369 // specified :ref:`resolver <envoy_api_field_core.SocketAddress.resolver_name>` 370 // in the Address). For LOGICAL or STRICT DNS, it is expected to be hostname, 371 // and will be resolved via DNS. 372 Address address = 1; 373 374 // The optional health check configuration. 375 message HealthCheckConfig { 376 // Optional alternative health check port value. 377 // 378 // By default the health check address port of an upstream host is the same 379 // as the host's serving address port. This provides an alternative health 380 // check port. Setting this with a non-zero value allows an upstream host 381 // to have different health check address port. 382 uint32 port_value = 1; 383 } 384 385 // The optional health check configuration is used as configuration for the 386 // health checker to contact the health checked host. 387 // 388 // .. attention:: 389 // 390 // This takes into effect only for upstream clusters with 391 // :ref:`active health checking <arch_overview_health_checking>` enabled. 392 HealthCheckConfig health_check_config = 2; 393} 394 395// An Endpoint that Envoy can route traffic to. 396message LbEndpoint { 397 // Upstream host identifier 398 Endpoint endpoint = 1; 399 400 // Optional health status when known and supplied by EDS server. 401 HealthStatus health_status = 2; 402 403 // The endpoint metadata specifies values that may be used by the load 404 // balancer to select endpoints in a cluster for a given request. The filter 405 // name should be specified as *envoy.lb*. An example boolean key-value pair 406 // is *canary*, providing the optional canary status of the upstream host. 407 // This may be matched against in a route's 408 // :ref:`RouteAction <envoy_api_msg_route.RouteAction>` metadata_match field 409 // to subset the endpoints considered in cluster load balancing. 410 Metadata metadata = 3; 411 412 // The optional load balancing weight of the upstream host, in the range 1 - 413 // 128. Envoy uses the load balancing weight in some of the built in load 414 // balancers. The load balancing weight for an endpoint is divided by the sum 415 // of the weights of all endpoints in the endpoint's locality to produce a 416 // percentage of traffic for the endpoint. This percentage is then further 417 // weighted by the endpoint's locality's load balancing weight from 418 // LocalityLbEndpoints. If unspecified, each host is presumed to have equal 419 // weight in a locality. 420 // 421 // .. attention:: 422 // 423 // The limit of 128 is somewhat arbitrary, but is applied due to performance 424 // concerns with the current implementation and can be removed when 425 // `this issue <https://github.com/envoyproxy/envoy/issues/1285>`_ is fixed. 426 UInt32Value load_balancing_weight = 4; 427} 428 429// A group of endpoints belonging to a Locality. 430// One can have multiple LocalityLbEndpoints for a locality, but this is 431// generally only done if the different groups need to have different load 432// balancing weights or different priorities. 433message LocalityLbEndpoints { 434 // Identifies location of where the upstream hosts run. 435 Locality locality = 1; 436 437 // The group of endpoints belonging to the locality specified. 438 repeated LbEndpoint lb_endpoints = 2; 439 440 // Optional: Per priority/region/zone/sub_zone weight - range 1-128. The load 441 // balancing weight for a locality is divided by the sum of the weights of all 442 // localities at the same priority level to produce the effective percentage 443 // of traffic for the locality. 444 // 445 // Locality weights are only considered when :ref:`locality weighted load 446 // balancing <arch_overview_load_balancing_locality_weighted_lb>` is 447 // configured. These weights are ignored otherwise. If no weights are 448 // specificed when locality weighted load balancing is enabled, the cluster is 449 // assumed to have a weight of 1. 450 // 451 // .. attention:: 452 // 453 // The limit of 128 is somewhat arbitrary, but is applied due to performance 454 // concerns with the current implementation and can be removed when 455 // `this issue <https://github.com/envoyproxy/envoy/issues/1285>`_ is fixed. 456 UInt32Value load_balancing_weight = 3; 457 458 // Optional: the priority for this LocalityLbEndpoints. If unspecified this will 459 // default to the highest priority (0). 460 // 461 // Under usual circumstances, Envoy will only select endpoints for the highest 462 // priority (0). In the event all endpoints for a particular priority are 463 // unavailable/unhealthy, Envoy will fail over to selecting endpoints for the 464 // next highest priority group. 465 // 466 // Priorities should range from 0 (highest) to N (lowest) without skipping. 467 uint32 priority = 5; 468} 469 470/////////////////////////////////////////////////////////////////////////////// 471 472message FractionalPercent { 473 // Specifies the numerator. Defaults to 0. 474 uint32 numerator = 1; 475 476 // Fraction percentages support several fixed denominator values. 477 enum DenominatorType { 478 // 100. 479 // 480 // **Example**: 1/100 = 1%. 481 HUNDRED = 0; 482 483 // 10,000. 484 // 485 // **Example**: 1/10000 = 0.01%. 486 TEN_THOUSAND = 1; 487 488 // 1,000,000. 489 // 490 // **Example**: 1/1000000 = 0.0001%. 491 MILLION = 2; 492 } 493 494 // Specifies the denominator. If the denominator specified is less than the numerator, the final 495 // fractional percentage is capped at 1 (100%). 496 DenominatorType denominator = 2; 497} 498 499/////////////////////////////////////////////////////////////////////////////// 500 501// [#protodoc-title: EDS] 502// Endpoint discovery :ref:`architecture overview <arch_overview_service_discovery_types_eds>` 503service EndpointDiscoveryService { 504 // The resource_names field in DiscoveryRequest specifies a list of clusters 505 // to subscribe to updates for. 506 rpc StreamEndpoints(stream DiscoveryRequest) returns (stream DiscoveryResponse) { 507 } 508} 509 510// Each route from RDS will map to a single cluster or traffic split across 511// clusters using weights expressed in the RDS WeightedCluster. 512// 513// With EDS, each cluster is treated independently from a LB perspective, with 514// LB taking place between the Localities within a cluster and at a finer 515// granularity between the hosts within a locality. For a given cluster, the 516// effective weight of a host is its load_balancing_weight multiplied by the 517// load_balancing_weight of its Locality. 518message ClusterLoadAssignment { 519 // Name of the cluster. This will be the :ref:`service_name 520 // <envoy_api_field_Cluster.EdsClusterConfig.service_name>` value if specified 521 // in the cluster :ref:`EdsClusterConfig 522 // <envoy_api_msg_Cluster.EdsClusterConfig>`. 523 string cluster_name = 1; 524 525 // List of endpoints to load balance to. 526 repeated LocalityLbEndpoints endpoints = 2; 527 528 // Load balancing policy settings. 529 message Policy { 530 reserved 1; 531 532 message DropOverload { 533 // Identifier for the policy specifying the drop. 534 string category = 1; 535 536 // Percentage of traffic that should be dropped for the category. 537 FractionalPercent drop_percentage = 2; 538 } 539 // Action to trim the overall incoming traffic to protect the upstream 540 // hosts. This action allows protection in case the hosts are unable to 541 // recover from an outage, or unable to autoscale or unable to handle 542 // incoming traffic volume for any reason. 543 // 544 // At the client each category is applied one after the other to generate 545 // the 'actual' drop percentage on all outgoing traffic. For example: 546 // 547 // .. code-block:: json 548 // 549 // { "drop_overloads": [ 550 // { "category": "throttle", "drop_percentage": 60 } 551 // { "category": "lb", "drop_percentage": 50 } 552 // ]} 553 // 554 // The actual drop percentages applied to the traffic at the clients will be 555 // "throttle"_drop = 60% 556 // "lb"_drop = 20% // 50% of the remaining 'actual' load, which is 40%. 557 // actual_outgoing_load = 20% // remaining after applying all categories. 558 repeated DropOverload drop_overloads = 2; 559 560 // Priority levels and localities are considered overprovisioned with this 561 // factor (in percentage). This means that we don't consider a priority 562 // level or locality unhealthy until the percentage of healthy hosts 563 // multiplied by the overprovisioning factor drops below 100. 564 // With the default value 140(1.4), Envoy doesn't consider a priority level 565 // or a locality unhealthy until their percentage of healthy hosts drops 566 // below 72%. 567 // Read more at :ref:`priority levels <arch_overview_load_balancing_priority_levels>` and 568 // :ref:`localities <arch_overview_load_balancing_locality_weighted_lb>`. 569 UInt32Value overprovisioning_factor = 3; 570 } 571 572 // Load balancing policy settings. 573 Policy policy = 4; 574} 575