mirror of
https://github.com/status-im/consul.git
synced 2025-02-10 12:46:32 +00:00
xRoute resource types contain a slice of parentRefs to services that they manipulate traffic for. All xRoutes that have a parentRef to given Service will be merged together to generate a ComputedRoutes resource name-aligned with that Service. This means that a write of an xRoute with 2 parent ref pointers will cause at most 2 reconciles for ComputedRoutes. If that xRoute's list of parentRefs were ever to be reduced, or otherwise lose an item, that subsequent map event will only emit events for the current set of refs. The removed ref will not cause the generated ComputedRoutes related to that service to be re-reconciled to omit the influence of that xRoute. To combat this, we will store on the ComputedRoutes resource a BoundResources []*pbresource.Reference field with references to all resources that were used to influence the generated output. When the routes controller reconciles, it will use a bimapper to index this influence, and the dependency mappers for the xRoutes will look themselves up in that index to discover additional (former) ComputedRoutes that need to be notified as well.
172 lines
5.5 KiB
Protocol Buffer
172 lines
5.5 KiB
Protocol Buffer
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
syntax = "proto3";
|
|
|
|
package hashicorp.consul.mesh.v2beta1;
|
|
|
|
import "pbcatalog/v2beta1/failover_policy.proto";
|
|
import "pbcatalog/v2beta1/protocol.proto";
|
|
import "pbcatalog/v2beta1/service_endpoints.proto";
|
|
import "pbmesh/v2beta1/common.proto";
|
|
import "pbmesh/v2beta1/destination_policy.proto";
|
|
import "pbmesh/v2beta1/grpc_route.proto";
|
|
import "pbmesh/v2beta1/http_route.proto";
|
|
import "pbmesh/v2beta1/http_route_retries.proto";
|
|
import "pbmesh/v2beta1/http_route_timeouts.proto";
|
|
import "pbresource/annotations.proto";
|
|
import "pbresource/resource.proto";
|
|
|
|
// This is a Resource type.
|
|
message ComputedRoutes {
|
|
option (hashicorp.consul.resource.spec) = {scope: SCOPE_NAMESPACE};
|
|
|
|
map<string, ComputedPortRoutes> ported_configs = 1;
|
|
|
|
// BoundReferences is a slice of mixed type references of resources that were
|
|
// involved in the formulation of this resource.
|
|
repeated hashicorp.consul.resource.Reference bound_references = 2;
|
|
}
|
|
|
|
message ComputedPortRoutes {
|
|
oneof config {
|
|
ComputedHTTPRoute http = 1;
|
|
ComputedGRPCRoute grpc = 2;
|
|
ComputedTCPRoute tcp = 3;
|
|
}
|
|
bool using_default_config = 4; // TODO
|
|
|
|
ParentReference parent_ref = 5;
|
|
// Protocol is the ParentRef.Port's protocol. It is based on the value in the
|
|
// Service object, but may differ depending upon which xRoutes are actually
|
|
// in use.
|
|
hashicorp.consul.catalog.v2beta1.Protocol protocol = 6;
|
|
|
|
// map key is an opaque string; like disco chain target name
|
|
map<string, BackendTargetDetails> targets = 7;
|
|
}
|
|
|
|
message ComputedHTTPRoute {
|
|
reserved 1; // hostnames
|
|
repeated ComputedHTTPRouteRule rules = 2;
|
|
}
|
|
|
|
message ComputedHTTPRouteRule {
|
|
repeated HTTPRouteMatch matches = 1;
|
|
repeated HTTPRouteFilter filters = 2;
|
|
repeated ComputedHTTPBackendRef backend_refs = 3;
|
|
HTTPRouteTimeouts timeouts = 4;
|
|
HTTPRouteRetries retries = 5;
|
|
}
|
|
|
|
message ComputedHTTPBackendRef {
|
|
// BackendTarget indicates which key in the targets map provides
|
|
// the rest of the configuration.
|
|
//
|
|
// If this field is set to the empty string, or is the sentinel value
|
|
// "NULL-ROUTE" is an indication that all of the traffic destined for this
|
|
// backend reference should be null routed in a format appropriate for the
|
|
// protocol (i.e. for HTTP use 5xx).
|
|
string backend_target = 1;
|
|
uint32 weight = 2;
|
|
repeated HTTPRouteFilter filters = 3;
|
|
}
|
|
|
|
message ComputedGRPCRoute {
|
|
reserved 1; // hostnames
|
|
repeated ComputedGRPCRouteRule rules = 2;
|
|
}
|
|
|
|
message ComputedGRPCRouteRule {
|
|
repeated GRPCRouteMatch matches = 1;
|
|
repeated GRPCRouteFilter filters = 2;
|
|
repeated ComputedGRPCBackendRef backend_refs = 3;
|
|
HTTPRouteTimeouts timeouts = 4;
|
|
HTTPRouteRetries retries = 5;
|
|
}
|
|
|
|
message ComputedGRPCBackendRef {
|
|
// BackendTarget indicates which key in the targets map provides
|
|
// the rest of the configuration.
|
|
//
|
|
// If this field is set to the empty string, or is the sentinel value
|
|
// "NULL-ROUTE" is an indication that all of the traffic destined for this
|
|
// backend reference should be null routed in a format appropriate for the
|
|
// protocol (i.e. for HTTP use 5xx).
|
|
string backend_target = 1;
|
|
uint32 weight = 2;
|
|
repeated GRPCRouteFilter filters = 3;
|
|
}
|
|
|
|
message ComputedTCPRoute {
|
|
repeated ComputedTCPRouteRule rules = 1;
|
|
}
|
|
|
|
message ComputedTCPRouteRule {
|
|
repeated ComputedTCPBackendRef backend_refs = 1;
|
|
}
|
|
|
|
// TODO: look into smuggling the target through a different typeURL, or just
|
|
// skip in favor of letting the caller do their own lookups?
|
|
message ComputedTCPBackendRef {
|
|
// BackendTarget indicates which key in the targets map provides
|
|
// the rest of the configuration.
|
|
//
|
|
// If this field is set to the empty string, or is the sentinel value
|
|
// "NULL-ROUTE" is an indication that all of the traffic destined for this
|
|
// backend reference should be null routed in a format appropriate for the
|
|
// protocol (i.e. for HTTP use 5xx).
|
|
string backend_target = 1;
|
|
uint32 weight = 2;
|
|
}
|
|
|
|
message BackendTargetDetails {
|
|
BackendTargetDetailsType type = 1;
|
|
BackendReference backend_ref = 2;
|
|
|
|
string mesh_port = 3;
|
|
ComputedFailoverConfig failover_config = 4;
|
|
DestinationConfig destination_config = 5;
|
|
|
|
reserved 6 to 20; // leaving a gap between computed and retroactively added fields.
|
|
|
|
// ServiceEndpointsID is not populated naturally and the field exists only for
|
|
// downstream consumers.
|
|
hashicorp.consul.resource.ID service_endpoints_id = 21;
|
|
|
|
// ServiceEndpoints is not populated naturally and the field exists only for
|
|
// downstream consumers.
|
|
hashicorp.consul.catalog.v2beta1.ServiceEndpoints service_endpoints = 22;
|
|
|
|
// IdentityRefs are not populated naturally and the field exists only for
|
|
// downstream consumers.
|
|
repeated hashicorp.consul.resource.Reference identity_refs = 23;
|
|
}
|
|
|
|
enum BackendTargetDetailsType {
|
|
BACKEND_TARGET_DETAILS_TYPE_UNSPECIFIED = 0;
|
|
|
|
// Direct means that the target is directly routable from a route. This does
|
|
// not mean that the target is not also indirect though.
|
|
BACKEND_TARGET_DETAILS_TYPE_DIRECT = 1;
|
|
|
|
// Indirect means that the target is not directly routable from a route.
|
|
//
|
|
// One example would be for a FailoverPolicy destination.
|
|
BACKEND_TARGET_DETAILS_TYPE_INDIRECT = 2;
|
|
}
|
|
|
|
message ComputedFailoverConfig {
|
|
repeated ComputedFailoverDestination destinations = 1;
|
|
hashicorp.consul.catalog.v2beta1.FailoverMode mode = 2;
|
|
repeated string regions = 3;
|
|
|
|
// SamenessGroup specifies the sameness group to failover to.
|
|
string sameness_group = 4;
|
|
}
|
|
|
|
message ComputedFailoverDestination {
|
|
// This must be a Service.
|
|
string backend_target = 1;
|
|
}
|