-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Configure Envoy alpn_protocols based on service protocol #14356
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
Changes from all commits
7b3722a
ffcd695
7e97544
c371d46
e2e342b
b9fd9a8
d0612af
b4cb253
bd6ec7f
0091d17
4346e02
2f7fb76
bf3f44f
e7122c3
2676416
8b2f2dd
f887940
b0a2657
18bd910
66bcd7e
3fe0200
7d9ad70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| xds: configure Envoy `alpn_protocols` for connect-proxy and ingress-gateway based on service protocol. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1073,6 +1073,19 @@ func (s *ResourceGenerator) injectConnectTLSForPublicListener(cfgSnap *proxycfg. | |
| return nil | ||
| } | ||
|
|
||
| func getAlpnProtocols(protocol string) []string { | ||
| var alpnProtocols []string | ||
|
|
||
| switch protocol { | ||
| case "grpc", "http2": | ||
oulman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| alpnProtocols = append(alpnProtocols, "h2", "http/1.1") | ||
| case "http": | ||
| alpnProtocols = append(alpnProtocols, "http/1.1") | ||
| } | ||
|
|
||
| return alpnProtocols | ||
| } | ||
|
|
||
| func createDownstreamTransportSocketForConnectTLS(cfgSnap *proxycfg.ConfigSnapshot, peerBundles []*pbpeering.PeeringTrustBundle) (*envoy_core_v3.TransportSocket, error) { | ||
| switch cfgSnap.Kind { | ||
| case structs.ServiceKindConnectProxy: | ||
|
|
@@ -1081,13 +1094,22 @@ func createDownstreamTransportSocketForConnectTLS(cfgSnap *proxycfg.ConfigSnapsh | |
| return nil, fmt.Errorf("cannot inject peering trust bundles for kind %q", cfgSnap.Kind) | ||
| } | ||
|
|
||
| // Determine listener protocol type from configured service protocol. Don't hard fail on a config typo, | ||
| //The parse func returns default config if there is an error, so it's safe to continue. | ||
| cfg, _ := ParseProxyConfig(cfgSnap.Proxy.Config) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value for protocol in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Right now calling getAlpnProtocols with |
||
| // Create TLS validation context for mTLS with leaf certificate and root certs. | ||
| tlsContext := makeCommonTLSContext( | ||
| cfgSnap.Leaf(), | ||
| cfgSnap.RootPEMs(), | ||
| makeTLSParametersFromProxyTLSConfig(cfgSnap.MeshConfigTLSIncoming()), | ||
| ) | ||
|
|
||
| if tlsContext != nil { | ||
| // Configure alpn protocols on CommonTLSContext | ||
| tlsContext.AlpnProtocols = getAlpnProtocols(cfg.Protocol) | ||
| } | ||
|
|
||
| // Inject peering trust bundles if this service is exported to peered clusters. | ||
| if len(peerBundles) > 0 { | ||
| spiffeConfig, err := makeSpiffeValidatorConfig( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.