// Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 syntax = "proto3"; package hashicorp.consul.mesh.v1alpha1; import "pbmesh/v1alpha1/common.proto"; import "pbmesh/v1alpha1/http_route.proto"; import "pbmesh/v1alpha1/http_route_retries.proto"; import "pbmesh/v1alpha1/http_route_timeouts.proto"; // NOTE: this should align to the GAMMA/gateway-api version, or at least be // easily translatable. // // https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1alpha2.GRPCRoute // // This is a Resource type. message GRPCRoute { // ParentRefs references the resources (usually Gateways) that a Route wants // to be attached to. Note that the referenced parent resource needs to allow // this for the attachment to be complete. For Gateways, that means the // Gateway needs to allow attachment from Routes of this kind and namespace. // // It is invalid to reference an identical parent more than once. It is valid // to reference multiple distinct sections within the same parent resource, // such as 2 Listeners within a Gateway. repeated ParentReference parent_refs = 1; repeated string hostnames = 2; // Rules are a list of GRPC matchers, filters and actions. repeated GRPCRouteRule rules = 3; } message GRPCRouteRule { repeated GRPCRouteMatch matches = 1; repeated GRPCRouteFilter filters = 2; repeated GRPCBackendRef backend_refs = 3; // ALTERNATIVE: Timeouts defines the timeouts that can be configured for an HTTP request. HTTPRouteTimeouts timeouts = 4; // ALTERNATIVE: HTTPRouteRetries retries = 5; } message GRPCRouteMatch { // Method specifies a gRPC request service/method matcher. If this field is // not specified, all services and methods will match. GRPCMethodMatch method = 1; // Headers specifies gRPC request header matchers. Multiple match values are // ANDed together, meaning, a request MUST match all the specified headers to // select the route. repeated GRPCHeaderMatch headers = 2; } message GRPCMethodMatch { // Type specifies how to match against the service and/or method. Support: // Core (Exact with service and method specified) GRPCMethodMatchType type = 1; // Value of the service to match against. If left empty or omitted, will // match any service. // // At least one of Service and Method MUST be a non-empty string. string service = 2; // Value of the method to match against. If left empty or omitted, will match // all services. // // At least one of Service and Method MUST be a non-empty string.} string method = 3; } enum GRPCMethodMatchType { GRPC_METHOD_MATCH_TYPE_UNSPECIFIED = 0; GRPC_METHOD_MATCH_TYPE_EXACT = 1; GRPC_METHOD_MATCH_TYPE_REGEX = 2; } message GRPCHeaderMatch { HeaderMatchType type = 1; string name = 2; string value = 3; } message GRPCRouteFilter { // RequestHeaderModifier defines a schema for a filter that modifies request // headers. HTTPHeaderFilter request_header_modifier = 1; // ResponseHeaderModifier defines a schema for a filter that modifies // response headers. HTTPHeaderFilter response_header_modifier = 2; // URLRewrite defines a schema for a filter that modifies a request during // forwarding. HTTPURLRewriteFilter url_rewrite = 5; } message GRPCBackendRef { BackendReference backend_ref = 1; // Weight specifies the proportion of requests forwarded to the referenced // backend. This is computed as weight/(sum of all weights in this // BackendRefs list). For non-zero values, there may be some epsilon from the // exact proportion defined here depending on the precision an implementation // supports. Weight is not a percentage and the sum of weights does not need // to equal 100. // //If only one backend is specified and it has a weight greater than 0, 100% //of the traffic is forwarded to that backend. If weight is set to 0, no //traffic should be forwarded for this entry. If unspecified, weight defaults //to 1. uint32 weight = 2; // Filters defined at this level should be executed if and only if the // request is being forwarded to the backend defined here. repeated GRPCRouteFilter filters = 3; }