Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate inbound/outbound for HTTP/2 #998

Merged
merged 5 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion pkg/xds/generator/inbound_proxy_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ func (g InboundProxyGenerator) Generate(ctx xds_context.Context, proxy *model.Pr
filterChainBuilder := func() *envoy_listeners.FilterChainBuilder {
filterChainBuilder := envoy_listeners.NewFilterChainBuilder()
switch protocol {
// configuration for HTTP case
case mesh_core.ProtocolHTTP:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still prefer :)

Suggested change
case mesh_core.ProtocolHTTP:
case mesh_core.ProtocolHTTP, mesh_core.ProtocolHTTP2:

// configuration for HTTP case
fallthrough
case mesh_core.ProtocolHTTP2:
filterChainBuilder.
Configure(envoy_listeners.HttpConnectionManager(localClusterName)).
Configure(envoy_listeners.FaultInjection(proxy.FaultInjections[endpoint])).
Expand Down
13 changes: 9 additions & 4 deletions pkg/xds/generator/outbound_proxy_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ func (g OutboundProxyGenerator) Generate(ctx xds_context.Context, proxy *model.P
Resource: listener,
})

// Generate route, routes are only applicable to the HTTP
if protocol == mesh_core.ProtocolHTTP {
// Generate route, routes are only applicable to the HTTP, HTTP/2 and GRPC protocols
switch protocol {
case mesh_core.ProtocolHTTP:
fallthrough
case mesh_core.ProtocolHTTP2:
fallthrough
case mesh_core.ProtocolGRPC:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and

Suggested change
case mesh_core.ProtocolGRPC:
case mesh_core.ProtocolHTTP, mesh_core.ProtocolHTTP2, mesh_core.ProtocolGRPC:

route, err := g.generateRDS(proxy, subsets, outbound)
if err != nil {
return nil, err
Expand Down Expand Up @@ -101,9 +106,9 @@ func (_ OutboundProxyGenerator) generateLDS(proxy *model.Proxy, subsets []envoy_
Configure(envoy_listeners.HttpAccessLog(meshName, envoy_listeners.TrafficDirectionOutbound, sourceService, serviceName, proxy.Logs[serviceName], proxy)).
Configure(envoy_listeners.HttpOutboundRoute(envoy_names.GetOutboundRouteName(serviceName))).
Configure(envoy_listeners.GrpcStats())
case mesh_core.ProtocolHTTP2:
fallthrough
case mesh_core.ProtocolHTTP:
fallthrough
case mesh_core.ProtocolHTTP2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case mesh_core.ProtocolHTTP2:
case mesh_core.ProtocolHTTP, mesh_core.ProtocolHTTP2:

filterChainBuilder.
Configure(envoy_listeners.HttpConnectionManager(serviceName)).
Configure(envoy_listeners.Tracing(proxy.TracingBackend)).
Expand Down
13 changes: 13 additions & 0 deletions pkg/xds/generator/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ var _ = Describe("InferServiceProtocol()", func() {
},
expected: mesh_core.ProtocolHTTP,
}),
Entry("one-item list: `kuma.io/protocol: http2`", testCase{
endpoints: []core_xds.Endpoint{
{Tags: map[string]string{"kuma.io/service": "backend", "kuma.io/protocol": "http2"}},
},
expected: mesh_core.ProtocolHTTP2,
}),
Entry("one-item list: `kuma.io/protocol: tcp`", testCase{
endpoints: []core_xds.Endpoint{
{Tags: map[string]string{"kuma.io/service": "backend", "kuma.io/protocol": "tcp"}},
Expand Down Expand Up @@ -80,6 +86,13 @@ var _ = Describe("InferServiceProtocol()", func() {
},
expected: mesh_core.ProtocolHTTP,
}),
Entry("multi-item list: `kuma.io/protocol: http` on every endpoint", testCase{
endpoints: []core_xds.Endpoint{
{Tags: map[string]string{"kuma.io/service": "backend", "region": "us", "kuma.io/protocol": "http2"}},
{Tags: map[string]string{"kuma.io/service": "backend", "region": "eu", "kuma.io/protocol": "http2"}},
},
expected: mesh_core.ProtocolHTTP2,
}),
Entry("multi-item list: `kuma.io/protocol: tcp` on every endpoint", testCase{
endpoints: []core_xds.Endpoint{
{Tags: map[string]string{"kuma.io/service": "backend", "region": "us", "kuma.io/protocol": "tcp"}},
Expand Down
66 changes: 51 additions & 15 deletions pkg/xds/generator/testdata/outbound-proxy/03.envoy.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ resources:
connectTimeout: 5s
edsClusterConfig:
edsConfig:
ads: {}
http2ProtocolOptions: {}
ads: { }
http2ProtocolOptions: { }
name: api-grpc
type: EDS
- name: api-http
Expand All @@ -159,8 +159,8 @@ resources:
connectTimeout: 5s
edsClusterConfig:
edsConfig:
ads: {}
http2ProtocolOptions: {}
ads: { }
http2ProtocolOptions: { }
name: api-http
outlierDetection:
enforcingConsecutive5xx: 100
Expand All @@ -175,8 +175,8 @@ resources:
connectTimeout: 5s
edsClusterConfig:
edsConfig:
ads: {}
http2ProtocolOptions: {}
ads: { }
http2ProtocolOptions: { }
name: api-http2
type: EDS
- name: api-tcp
Expand All @@ -185,8 +185,8 @@ resources:
connectTimeout: 5s
edsClusterConfig:
edsConfig:
ads: {}
http2ProtocolOptions: {}
ads: { }
http2ProtocolOptions: { }
name: api-tcp
type: EDS
- name: backend
Expand All @@ -195,8 +195,8 @@ resources:
connectTimeout: 5s
edsClusterConfig:
edsConfig:
ads: {}
http2ProtocolOptions: {}
ads: { }
http2ProtocolOptions: { }
name: backend
type: EDS
- name: db
Expand All @@ -205,8 +205,8 @@ resources:
connectTimeout: 5s
edsClusterConfig:
edsConfig:
ads: {}
http2ProtocolOptions: {}
ads: { }
http2ProtocolOptions: { }
lbSubsetConfig:
fallbackPolicy: ANY_ENDPOINT
subsetSelectors:
Expand All @@ -215,6 +215,24 @@ resources:
- role
name: db
type: EDS
- name: outbound:api-grpc
resource:
'@type': type.googleapis.com/envoy.api.v2.RouteConfiguration
name: outbound:api-grpc
requestHeadersToAdd:
- header:
key: x-kuma-tags
value: '&kuma.io/service=gateway&'
validateClusters: true
virtualHosts:
- domains:
- '*'
name: api-grpc
routes:
- match:
prefix: /
route:
cluster: api-grpc
- name: outbound:api-http
resource:
'@type': type.googleapis.com/envoy.api.v2.RouteConfiguration
Expand All @@ -233,6 +251,24 @@ resources:
prefix: /
route:
cluster: api-http
- name: outbound:api-http2
resource:
'@type': type.googleapis.com/envoy.api.v2.RouteConfiguration
name: outbound:api-http2
requestHeadersToAdd:
- header:
key: x-kuma-tags
value: '&kuma.io/service=gateway&'
validateClusters: true
virtualHosts:
- domains:
- '*'
name: api-http2
routes:
- match:
prefix: /
route:
cluster: api-http2
- name: outbound:127.0.0.1:18080
resource:
'@type': type.googleapis.com/envoy.api.v2.Listener
Expand Down Expand Up @@ -273,7 +309,7 @@ resources:
- name: envoy.router
rds:
configSource:
ads: {}
ads: { }
routeConfigName: outbound:api-http
statPrefix: api-http
name: outbound:127.0.0.1:40001
Expand Down Expand Up @@ -321,7 +357,7 @@ resources:
- name: envoy.router
rds:
configSource:
ads: {}
ads: { }
routeConfigName: outbound:api-http2
statPrefix: api-http2
name: outbound:127.0.0.1:40003
Expand All @@ -347,7 +383,7 @@ resources:
- name: envoy.router
rds:
configSource:
ads: {}
ads: { }
routeConfigName: outbound:api-grpc
statPrefix: api-grpc
name: outbound:127.0.0.1:40004
Expand Down