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

Add configurable listener ALPN protocols to enable downstream http2 #71

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ The Yggdrasil-specific metrics which are available from the API are:
## Flags
```
--address string yggdrasil envoy control plane listen address (default "0.0.0.0:8080")
--alpn-protocols strings exposed listener ALPN protocols
--ca string trustedCA
--cert string certfile
--config string config file
Expand Down
4 changes: 4 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type config struct {
UseRemoteAddress bool `json:"useRemoteAddress"`
HttpExtAuthz envoy.HttpExtAuthz `json:"httpExtAuthz"`
HttpGrpcLogger envoy.HttpGrpcLogger `json:"httpGrpcLogger"`
AlpnProtocols []string `json:"alpnProtocols"`
}

// Hasher returns node ID as an ID
Expand Down Expand Up @@ -104,6 +105,7 @@ func init() {
rootCmd.PersistentFlags().Bool("http-ext-authz-allow-partial-message", true, "When this field is true, Envoy will buffer the message until max_request_bytes is reached")
rootCmd.PersistentFlags().Bool("http-ext-authz-pack-as-bytes", false, "When this field is true, Envoy will send the body as raw bytes.")
rootCmd.PersistentFlags().Bool("http-ext-authz-failure-mode-allow", true, "Changes filters behaviour on errors")
rootCmd.PersistentFlags().StringSlice("alpn-protocols", []string{}, "exposed listener ALPN protocols")
viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug"))
viper.BindPFlag("address", rootCmd.PersistentFlags().Lookup("address"))
viper.BindPFlag("healthAddress", rootCmd.PersistentFlags().Lookup("health-address"))
Expand Down Expand Up @@ -134,6 +136,7 @@ func init() {
viper.BindPFlag("httpExtAuthz.allowPartialMessage", rootCmd.PersistentFlags().Lookup("http-ext-authz-allow-partial-message"))
viper.BindPFlag("httpExtAuthz.packAsBytes", rootCmd.PersistentFlags().Lookup("http-ext-authz-pack-as-bytes"))
viper.BindPFlag("httpExtAuthz.FailureModeAllow", rootCmd.PersistentFlags().Lookup("http-ext-authz-failure-mode-allow"))
viper.BindPFlag("alpnProtocols", rootCmd.PersistentFlags().Lookup("alpn-protocols"))
}

func initConfig() {
Expand Down Expand Up @@ -230,6 +233,7 @@ func main(*cobra.Command, []string) error {
envoy.WithHttpExtAuthzCluster(c.HttpExtAuthz),
envoy.WithHttpGrpcLogger(c.HttpGrpcLogger),
envoy.WithDefaultRetryOn(viper.GetString("retryOn")),
envoy.WithAlpnProtocols(viper.GetStringSlice("alpnProtocols")),
)
snapshotter := envoy.NewSnapshotter(envoyCache, configurator, aggregator)

Expand Down
1 change: 1 addition & 0 deletions pkg/envoy/boilerplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func (c *KubernetesConfigurator) makeFilterChain(certificate Certificate, virtua

tls := &auth.DownstreamTlsContext{}
tls.CommonTlsContext = &auth.CommonTlsContext{
AlpnProtocols: c.alpnProtocols,
TlsCertificates: []*auth.TlsCertificate{
{
CertificateChain: &core.DataSource{
Expand Down
1 change: 1 addition & 0 deletions pkg/envoy/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type KubernetesConfigurator struct {
httpExtAuthz HttpExtAuthz
httpGrpcLogger HttpGrpcLogger
defaultRetryOn string
alpnProtocols []string

previousConfig *envoyConfiguration
listenerVersion string
Expand Down
7 changes: 7 additions & 0 deletions pkg/envoy/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ func WithDefaultRetryOn(defaultRetryOn string) option {
c.defaultRetryOn = defaultRetryOn
}
}

// WithAlpnProtocols configures the the exposed listener ALPN protocols
func WithAlpnProtocols(alpnProtocols []string) option {
return func(c *KubernetesConfigurator) {
c.alpnProtocols = alpnProtocols
}
}