@@ -7,13 +7,17 @@ import (
7
7
8
8
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
9
9
envoy_config_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
10
+ envoy_upstreams_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/upstreams/http/v3"
11
+ "google.golang.org/protobuf/proto"
12
+ "google.golang.org/protobuf/types/known/anypb"
10
13
"google.golang.org/protobuf/types/known/durationpb"
11
14
"istio.io/istio/pkg/kube/krt"
12
15
13
16
"k8s.io/apimachinery/pkg/runtime/schema"
14
17
15
18
extensionsplug "github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugin"
16
19
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/ir"
20
+ "github.com/kgateway-dev/kgateway/v2/internal/kgateway/utils"
17
21
)
18
22
19
23
var (
@@ -78,6 +82,36 @@ func (t *BackendTranslator) runPlugins(
78
82
}
79
83
}
80
84
85
+ var (
86
+ h2Options = func () * anypb.Any {
87
+ http2ProtocolOptions := & envoy_upstreams_v3.HttpProtocolOptions {
88
+ UpstreamProtocolOptions : & envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig_ {
89
+ ExplicitHttpConfig : & envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig {
90
+ ProtocolConfig : & envoy_upstreams_v3.HttpProtocolOptions_ExplicitHttpConfig_Http2ProtocolOptions {
91
+ Http2ProtocolOptions : & envoy_config_core_v3.Http2ProtocolOptions {},
92
+ },
93
+ },
94
+ },
95
+ }
96
+
97
+ a , err := utils .MessageToAny (http2ProtocolOptions )
98
+ if err != nil {
99
+ // should never happen - all values are known ahead of time.
100
+ panic (err )
101
+ }
102
+ return a
103
+ }()
104
+ )
105
+
106
+ func translateAppProtocol (appProtocol ir.AppProtocol ) map [string ]* anypb.Any {
107
+ typedExtensionProtocolOptions := map [string ]* anypb.Any {}
108
+ switch appProtocol {
109
+ case ir .HTTP2AppProtocol :
110
+ typedExtensionProtocolOptions ["envoy.extensions.upstreams.http.v3.HttpProtocolOptions" ] = proto .Clone (h2Options ).(* anypb.Any )
111
+ }
112
+ return typedExtensionProtocolOptions
113
+ }
114
+
81
115
// initializeCluster creates a default envoy cluster with minimal configuration,
82
116
// that will then be augmented by various backend plugins
83
117
func initializeCluster (u ir.BackendObjectIR ) * envoy_config_cluster_v3.Cluster {
@@ -92,7 +126,9 @@ func initializeCluster(u ir.BackendObjectIR) *envoy_config_cluster_v3.Cluster {
92
126
// defaults to Cluster_USE_CONFIGURED_PROTOCOL
93
127
// ProtocolSelection: envoy_config_cluster_v3.Cluster_ClusterProtocolSelection(upstream.GetProtocolSelection()),
94
128
// this field can be overridden by plugins
95
- ConnectTimeout : durationpb .New (ClusterConnectionTimeout ),
129
+ ConnectTimeout : durationpb .New (ClusterConnectionTimeout ),
130
+ TypedExtensionProtocolOptions : translateAppProtocol (u .AppProtocol ),
131
+
96
132
// Http2ProtocolOptions: getHttp2options(upstream),
97
133
// IgnoreHealthOnHostRemoval: upstream.GetIgnoreHealthOnHostRemoval().GetValue(),
98
134
// RespectDnsTtl: upstream.GetRespectDnsTtl().GetValue(),
0 commit comments