xref: /aosp_15_r20/external/grpc-grpc/src/proto/grpc/testing/xds/v3/cluster.proto (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1// Copyright 2020 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// Local copy of Envoy xDS proto file, used for testing only.
16
17syntax = "proto3";
18
19package envoy.config.cluster.v3;
20
21import "src/proto/grpc/testing/xds/v3/base.proto";
22import "src/proto/grpc/testing/xds/v3/config_source.proto";
23import "src/proto/grpc/testing/xds/v3/endpoint.proto";
24import "src/proto/grpc/testing/xds/v3/extension.proto";
25import "src/proto/grpc/testing/xds/v3/health_check.proto";
26import "src/proto/grpc/testing/xds/v3/outlier_detection.proto";
27
28import "google/protobuf/any.proto";
29import "google/protobuf/wrappers.proto";
30
31enum RoutingPriority {
32  DEFAULT = 0;
33  HIGH = 1;
34}
35
36message CircuitBreakers {
37  message Thresholds {
38    RoutingPriority priority = 1;
39    google.protobuf.UInt32Value max_requests = 4;
40  }
41  repeated Thresholds thresholds = 1;
42}
43
44// Extended cluster type.
45message CustomClusterType {
46  // The type of the cluster to instantiate. The name must match a supported cluster type.
47  string name = 1;
48
49  // Cluster specific configuration which depends on the cluster being instantiated.
50  // See the supported cluster for further documentation.
51  google.protobuf.Any typed_config = 2;
52}
53
54// [#protodoc-title: Cluster configuration]
55
56// Configuration for a single upstream cluster.
57// [#next-free-field: 48]
58message Cluster {
59  // Refer to :ref:`service discovery type <arch_overview_service_discovery_types>`
60  // for an explanation on each type.
61  enum DiscoveryType {
62    // Refer to the :ref:`static discovery type<arch_overview_service_discovery_types_static>`
63    // for an explanation.
64    STATIC = 0;
65
66    // Refer to the :ref:`strict DNS discovery
67    // type<arch_overview_service_discovery_types_strict_dns>`
68    // for an explanation.
69    STRICT_DNS = 1;
70
71    // Refer to the :ref:`logical DNS discovery
72    // type<arch_overview_service_discovery_types_logical_dns>`
73    // for an explanation.
74    LOGICAL_DNS = 2;
75
76    // Refer to the :ref:`service discovery type<arch_overview_service_discovery_types_eds>`
77    // for an explanation.
78    EDS = 3;
79
80    // Refer to the :ref:`original destination discovery
81    // type<arch_overview_service_discovery_types_original_destination>`
82    // for an explanation.
83    ORIGINAL_DST = 4;
84  }
85
86  // Refer to :ref:`load balancer type <arch_overview_load_balancing_types>` architecture
87  // overview section for information on each type.
88  enum LbPolicy {
89    reserved 4;
90
91    reserved "ORIGINAL_DST_LB";
92
93    // Refer to the :ref:`round robin load balancing
94    // policy<arch_overview_load_balancing_types_round_robin>`
95    // for an explanation.
96    ROUND_ROBIN = 0;
97
98    // Refer to the :ref:`least request load balancing
99    // policy<arch_overview_load_balancing_types_least_request>`
100    // for an explanation.
101    LEAST_REQUEST = 1;
102
103    // Refer to the :ref:`ring hash load balancing
104    // policy<arch_overview_load_balancing_types_ring_hash>`
105    // for an explanation.
106    RING_HASH = 2;
107
108    // Refer to the :ref:`random load balancing
109    // policy<arch_overview_load_balancing_types_random>`
110    // for an explanation.
111    RANDOM = 3;
112
113    // Refer to the :ref:`Maglev load balancing policy<arch_overview_load_balancing_types_maglev>`
114    // for an explanation.
115    MAGLEV = 5;
116
117    // This load balancer type must be specified if the configured cluster provides a cluster
118    // specific load balancer. Consult the configured cluster's documentation for whether to set
119    // this option or not.
120    CLUSTER_PROVIDED = 6;
121
122    // [#not-implemented-hide:] Use the new :ref:`load_balancing_policy
123    // <envoy_api_field_config.cluster.v3.Cluster.load_balancing_policy>` field to determine the LB policy.
124    // [#next-major-version: In the v3 API, we should consider deprecating the lb_policy field
125    // and instead using the new load_balancing_policy field as the one and only mechanism for
126    // configuring this.]
127    LOAD_BALANCING_POLICY_CONFIG = 7;
128  }
129
130  // Only valid when discovery type is EDS.
131  message EdsClusterConfig {
132    // Configuration for the source of EDS updates for this Cluster.
133    core.v3.ConfigSource eds_config = 1;
134
135    // Optional alternative to cluster name to present to EDS. This does not
136    // have the same restrictions as cluster name, i.e. it may be arbitrary
137    // length.
138    string service_name = 2;
139  }
140
141  message CommonLbConfig {
142    core.v3.HealthStatusSet override_host_status = 8;
143  }
144
145  // Supplies the name of the cluster which must be unique across all clusters.
146  // The cluster name is used when emitting
147  // :ref:`statistics <config_cluster_manager_cluster_stats>` if :ref:`alt_stat_name
148  // <envoy_api_field_config.cluster.v3.Cluster.alt_stat_name>` is not provided.
149  // Any ``:`` in the cluster name will be converted to ``_`` when emitting statistics.
150  string name = 1;
151
152  oneof cluster_discovery_type {
153    // The :ref:`service discovery type <arch_overview_service_discovery_types>`
154    // to use for resolving the cluster.
155    DiscoveryType type = 2;
156
157    // The custom cluster type.
158    CustomClusterType cluster_type = 38;
159  }
160
161  // Configuration to use for EDS updates for the Cluster.
162  EdsClusterConfig eds_cluster_config = 3;
163
164  // Specific configuration for the :ref:`RingHash<arch_overview_load_balancing_types_ring_hash>`
165  // load balancing policy.
166  message RingHashLbConfig {
167    // The hash function used to hash hosts onto the ketama ring.
168    enum HashFunction {
169      // Use `xxHash <https://github.com/Cyan4973/xxHash>`_, this is the default hash function.
170      XX_HASH = 0;
171      MURMUR_HASH_2 = 1;
172    }
173
174    reserved 2;
175
176    // Minimum hash ring size. The larger the ring is (that is, the more hashes there are for each
177    // provided host) the better the request distribution will reflect the desired weights. Defaults
178    // to 1024 entries, and limited to 8M entries. See also
179    // :ref:`maximum_ring_size<envoy_api_field_config.cluster.v3.Cluster.RingHashLbConfig.maximum_ring_size>`.
180    google.protobuf.UInt64Value minimum_ring_size = 1;
181
182    // The hash function used to hash hosts onto the ketama ring. The value defaults to
183    // :ref:`XX_HASH<envoy_api_enum_value_config.cluster.v3.Cluster.RingHashLbConfig.HashFunction.XX_HASH>`.
184    HashFunction hash_function = 3;
185
186    // Maximum hash ring size. Defaults to 8M entries, and limited to 8M entries, but can be lowered
187    // to further constrain resource use. See also
188    // :ref:`minimum_ring_size<envoy_api_field_config.cluster.v3.Cluster.RingHashLbConfig.minimum_ring_size>`.
189    google.protobuf.UInt64Value maximum_ring_size = 4;
190  }
191
192  // The :ref:`load balancer type <arch_overview_load_balancing_types>` to use
193  // when picking a host in the cluster.
194  LbPolicy lb_policy = 6;
195
196  // Setting this is required for specifying members of
197  // :ref:`STATIC<envoy_api_enum_value_config.cluster.v3.Cluster.DiscoveryType.STATIC>`,
198  // :ref:`STRICT_DNS<envoy_api_enum_value_config.cluster.v3.Cluster.DiscoveryType.STRICT_DNS>`
199  // or :ref:`LOGICAL_DNS<envoy_api_enum_value_config.cluster.v3.Cluster.DiscoveryType.LOGICAL_DNS>` clusters.
200  // This field supersedes the *hosts* field in the v2 API.
201  //
202  // .. attention::
203  //
204  //   Setting this allows non-EDS cluster types to contain embedded EDS equivalent
205  //   :ref:`endpoint assignments<envoy_api_msg_config.endpoint.v3.ClusterLoadAssignment>`.
206  //
207  endpoint.v3.ClusterLoadAssignment load_assignment = 33;
208
209  CircuitBreakers circuit_breakers = 10;
210
211  // If specified, outlier detection will be enabled for this upstream cluster.
212  // Each of the configuration values can be overridden via
213  // :ref:`runtime values <config_cluster_manager_cluster_runtime_outlier_detection>`.
214  OutlierDetection outlier_detection = 19;
215
216  // Optional configuration for the load balancing algorithm selected by
217  // LbPolicy. Currently only
218  // :ref:`RING_HASH<envoy_api_enum_value_config.cluster.v3.Cluster.LbPolicy.RING_HASH>`,
219  // Specifying ring_hash_lb_config without setting the corresponding
220  // LbPolicy will generate an error at runtime.
221  oneof lb_config {
222    // Optional configuration for the Ring Hash load balancing policy.
223    RingHashLbConfig ring_hash_lb_config = 23;
224  }
225
226  CommonLbConfig common_lb_config = 27;
227
228  // Optional custom transport socket implementation to use for upstream connections.
229  // To setup TLS, set a transport socket with name `tls` and
230  // :ref:`UpstreamTlsContexts <envoy_api_msg_extensions.transport_sockets.tls.v3.UpstreamTlsContext>` in the `typed_config`.
231  // If no transport socket configuration is specified, new connections
232  // will be set up with plaintext.
233  core.v3.TransportSocket transport_socket = 24;
234
235  // If this field is set and is supported by the client, it will supersede the value of
236  // :ref:`lb_policy<envoy_v3_api_field_config.cluster.v3.Cluster.lb_policy>`.
237  LoadBalancingPolicy load_balancing_policy = 41;
238
239  // [#not-implemented-hide:]
240  // If present, tells the client where to send load reports via LRS. If not present, the
241  // client will fall back to a client-side default, which may be either (a) don't send any
242  // load reports or (b) send load reports for all clusters to a single default server
243  // (which may be configured in the bootstrap file).
244  //
245  // Note that if multiple clusters point to the same LRS server, the client may choose to
246  // create a separate stream for each cluster or it may choose to coalesce the data for
247  // multiple clusters onto a single stream. Either way, the client must make sure to send
248  // the data for any given cluster on no more than one stream.
249  //
250  // [#next-major-version: In the v3 API, we should consider restructuring this somehow,
251  // maybe by allowing LRS to go on the ADS stream, or maybe by moving some of the negotiation
252  // from the LRS stream here.]
253  core.v3.ConfigSource lrs_server = 42;
254
255  // The Metadata field can be used to provide additional information about the
256  // cluster. It can be used for stats, logging, and varying filter behavior.
257  // Fields should use reverse DNS notation to denote which entity within Envoy
258  // will need the information. For instance, if the metadata is intended for
259  // the Router filter, the filter name should be specified as ``envoy.filters.http.router``.
260  core.v3.Metadata metadata = 25;
261
262  core.v3.TypedExtensionConfig upstream_config = 48;
263}
264
265// Extensible load balancing policy configuration.
266//
267// Every LB policy defined via this mechanism will be identified via a unique name using reverse
268// DNS notation. If the policy needs configuration parameters, it must define a message for its
269// own configuration, which will be stored in the config field. The name of the policy will tell
270// clients which type of message they should expect to see in the config field.
271//
272// Note that there are cases where it is useful to be able to independently select LB policies
273// for choosing a locality and for choosing an endpoint within that locality. For example, a
274// given deployment may always use the same policy to choose the locality, but for choosing the
275// endpoint within the locality, some clusters may use weighted-round-robin, while others may
276// use some sort of session-based balancing.
277//
278// This can be accomplished via hierarchical LB policies, where the parent LB policy creates a
279// child LB policy for each locality. For each request, the parent chooses the locality and then
280// delegates to the child policy for that locality to choose the endpoint within the locality.
281//
282// To facilitate this, the config message for the top-level LB policy may include a field of
283// type LoadBalancingPolicy that specifies the child policy.
284message LoadBalancingPolicy {
285  message Policy {
286    reserved 2, 1, 3;
287
288    reserved "config", "name", "typed_config";
289
290    core.v3.TypedExtensionConfig typed_extension_config = 4;
291  }
292
293  // Each client will iterate over the list in order and stop at the first policy that it
294  // supports. This provides a mechanism for starting to use new LB policies that are not yet
295  // supported by all clients.
296  repeated Policy policies = 1;
297}
298