Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ type EnvoyProxySpec struct {
//
// - envoy.filters.http.grpc_web
//
// - envoy.filters.http.grpc_json_transcoder
//
// - envoy.filters.http.grpc_stats
//
// - envoy.filters.http.credential_injector
Expand Down Expand Up @@ -388,7 +390,7 @@ type FilterPosition struct {
}

// EnvoyFilter defines the type of Envoy HTTP filter.
// +kubebuilder:validation:Enum=envoy.filters.http.custom_response;envoy.filters.http.health_check;envoy.filters.http.fault;envoy.filters.http.cors;envoy.filters.http.csrf;envoy.filters.http.header_mutation;envoy.filters.http.ext_authz;envoy.filters.http.api_key_auth;envoy.filters.http.basic_auth;envoy.filters.http.oauth2;envoy.filters.http.jwt_authn;envoy.filters.http.stateful_session;envoy.filters.http.buffer;envoy.filters.http.lua;envoy.filters.http.ext_proc;envoy.filters.http.wasm;envoy.filters.http.dynamic_modules;envoy.filters.http.geoip;envoy.filters.http.rbac;envoy.filters.http.local_ratelimit;envoy.filters.http.ratelimit;envoy.filters.http.bandwidth_limit;envoy.filters.http.grpc_web;envoy.filters.http.grpc_stats;envoy.filters.http.credential_injector;envoy.filters.http.compressor;envoy.filters.http.dynamic_forward_proxy
// +kubebuilder:validation:Enum=envoy.filters.http.custom_response;envoy.filters.http.health_check;envoy.filters.http.fault;envoy.filters.http.cors;envoy.filters.http.csrf;envoy.filters.http.header_mutation;envoy.filters.http.ext_authz;envoy.filters.http.api_key_auth;envoy.filters.http.basic_auth;envoy.filters.http.oauth2;envoy.filters.http.jwt_authn;envoy.filters.http.stateful_session;envoy.filters.http.buffer;envoy.filters.http.lua;envoy.filters.http.ext_proc;envoy.filters.http.wasm;envoy.filters.http.dynamic_modules;envoy.filters.http.geoip;envoy.filters.http.rbac;envoy.filters.http.local_ratelimit;envoy.filters.http.ratelimit;envoy.filters.http.bandwidth_limit;envoy.filters.http.grpc_web;envoy.filters.http.grpc_json_transcoder;envoy.filters.http.grpc_stats;envoy.filters.http.credential_injector;envoy.filters.http.compressor;envoy.filters.http.dynamic_forward_proxy
type EnvoyFilter string

const (
Expand Down Expand Up @@ -462,6 +464,9 @@ const (
// EnvoyFilterGRPCWeb defines the Envoy HTTP gRPC-web filter.
EnvoyFilterGRPCWeb EnvoyFilter = "envoy.filters.http.grpc_web"

// EnvoyFilterGRPCJSONTranscoder defines the Envoy HTTP gRPC-JSON transcoder filter.
EnvoyFilterGRPCJSONTranscoder EnvoyFilter = "envoy.filters.http.grpc_json_transcoder"

// EnvoyFilterGRPCStats defines the Envoy HTTP gRPC stats filter.
EnvoyFilterGRPCStats EnvoyFilter = "envoy.filters.http.grpc_stats"

Expand Down
100 changes: 100 additions & 0 deletions api/v1alpha1/grpc_json_transcoder_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

// GRPCJSONTranscoder defines the configuration for gRPC-JSON transcoding.
type GRPCJSONTranscoder struct {
// ProtoDescriptor defines how to obtain the protocol buffer descriptor set.
// This is required for the transcoder to understand the gRPC service definition.
ProtoDescriptor ProtoDescriptor `json:"protoDescriptor"`

// Services defines the gRPC services that should be transcoded.
//
// If not specified, every service declared by the proto files in the descriptor is
// transcoded, excluding services that come from imported files.
//
// Entries must be unique. Envoy registers every method of each listed service into one
// path matcher, and a repeated service silently stops the filter from transcoding.
// +optional
// +listType=set
Services []string `json:"services,omitempty"`

// PrintOptions defines the output format options for JSON conversion.
// +optional
PrintOptions *JSONPrintOptions `json:"printOptions,omitempty"`

// MatchIncomingRequestRoute keeps the route that matched the incoming request after
// the transcoder rewrites the path to the gRPC method.
//
// When false (the default), the rewritten path is matched against the routing table
// again, so a route matching the gRPC method must also exist or the request is
// answered with 404. Either a GRPCRoute for the service, or an HTTPRoute matching
// `/<package>.<Service>/<Method>`, satisfies this.
// +optional
MatchIncomingRequestRoute *bool `json:"matchIncomingRequestRoute,omitempty"`

// IgnoredQueryParameters defines query parameters to ignore during transcoding.
// +optional
// +listType=set
IgnoredQueryParameters []string `json:"ignoredQueryParameters,omitempty"`

// AutoMapping routes methods that carry no `google.api.http` option, by generating a
// default binding of `POST /<package>.<Service>/<Method>` with the request message as
// the JSON body. Methods that do carry the option are unaffected.
// +optional
AutoMapping *bool `json:"autoMapping,omitempty"`

// IgnoreUnknownQueryParameters ignores query parameters that cannot be mapped to a
// gRPC request field. Set this when the query parameters are not known in advance;
// otherwise list them in IgnoredQueryParameters.
//
// When false (the default), a request carrying an unmappable parameter is not
// transcoded at all and is forwarded to the backend unchanged. A gRPC backend then
// rejects it for arriving without a gRPC content-type, so the failure surfaces as a
// content-type error that never names the query parameter.
// +optional
IgnoreUnknownQueryParameters *bool `json:"ignoreUnknownQueryParameters,omitempty"`

// ConvertGRPCStatus enables converting gRPC status to HTTP status codes.
// If true, gRPC status codes are converted to appropriate HTTP status codes.
// +optional
ConvertGRPCStatus *bool `json:"convertGRPCStatus,omitempty"`
}

// ProtoDescriptor locates the protocol buffer descriptor set describing the gRPC services.
// +kubebuilder:validation:XValidation:rule="size(self.valueRef.group) == 0 && self.valueRef.kind == 'ConfigMap'",message="valueRef must refer to a core ConfigMap"
type ProtoDescriptor struct {
// ValueRef is a reference to a ConfigMap in the same namespace holding the descriptor.
// A `binaryData` entry is used as-is, and is found either under the key
// `proto-descriptor` or as the ConfigMap's only entry. A `data` entry must be
// base64-encoded and must use the `proto-descriptor` key.
//
// Generate the descriptor with `protoc --include_imports`; without the imported files
// Envoy cannot build a descriptor pool.
ValueRef gwapiv1.LocalObjectReference `json:"valueRef"`
}

// JSONPrintOptions defines options for JSON output formatting.
type JSONPrintOptions struct {
// AddWhitespace adds whitespace for pretty-printing JSON output.
// +optional
AddWhitespace *bool `json:"addWhitespace,omitempty"`

// AlwaysPrintPrimitiveFields always prints primitive fields even if they have default values.
// +optional
AlwaysPrintPrimitiveFields *bool `json:"alwaysPrintPrimitiveFields,omitempty"`

// AlwaysPrintEnumsAsInts always prints enum values as integers instead of strings.
// +optional
AlwaysPrintEnumsAsInts *bool `json:"alwaysPrintEnumsAsInts,omitempty"`

// PreserveProtoFieldNames preserves proto field names in JSON output instead
// of converting them to camelCase.
// +optional
PreserveProtoFieldNames *bool `json:"preserveProtoFieldNames,omitempty"`
}
10 changes: 10 additions & 0 deletions api/v1alpha1/httproutefilter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ type HTTPRouteFilterSpec struct {
DirectResponse *HTTPDirectResponseFilter `json:"directResponse,omitempty"`
// +optional
CredentialInjection *HTTPCredentialInjectionFilter `json:"credentialInjection,omitempty"`
// GRPCJSONTranscoder transcodes a JSON/HTTP request into a gRPC call, and the gRPC
// response back into JSON.
//
// This filter is only supported at the rule level of an HTTPRoute. Referencing it
// from a GRPCRoute, or from a backendRef, makes the route unresolvable: the incoming
// request must be JSON/HTTP for there to be anything to transcode, and a backendRef
// filter has no route table on which to enable the transcoder.
//
// +optional
GRPCJSONTranscoder *GRPCJSONTranscoder `json:"grpcJSONTranscoder,omitempty"`
// Matches defines additional matching criteria for the HTTPRoute rule.
// As with HTTPRouteRule.Matches, the rule is matched if any one match applies.
// When both HTTPRouteRule.Matches and HTTPRouteFilter.Matches are set, the
Expand Down
107 changes: 107 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ spec:

- envoy.filters.http.grpc_web

- envoy.filters.http.grpc_json_transcoder

- envoy.filters.http.grpc_stats

- envoy.filters.http.credential_injector
Expand Down Expand Up @@ -529,6 +531,7 @@ spec:
- envoy.filters.http.ratelimit
- envoy.filters.http.bandwidth_limit
- envoy.filters.http.grpc_web
- envoy.filters.http.grpc_json_transcoder
- envoy.filters.http.grpc_stats
- envoy.filters.http.credential_injector
- envoy.filters.http.compressor
Expand Down Expand Up @@ -562,6 +565,7 @@ spec:
- envoy.filters.http.ratelimit
- envoy.filters.http.bandwidth_limit
- envoy.filters.http.grpc_web
- envoy.filters.http.grpc_json_transcoder
- envoy.filters.http.grpc_stats
- envoy.filters.http.credential_injector
- envoy.filters.http.compressor
Expand Down Expand Up @@ -593,6 +597,7 @@ spec:
- envoy.filters.http.ratelimit
- envoy.filters.http.bandwidth_limit
- envoy.filters.http.grpc_web
- envoy.filters.http.grpc_json_transcoder
- envoy.filters.http.grpc_stats
- envoy.filters.http.credential_injector
- envoy.filters.http.compressor
Expand Down
Loading
Loading