Skip to content

Commit 1410533

Browse files
committed
UPSTREAM 3454: disable HTTP2 for webhook server
Bug reference: OCPBUGS-22344
1 parent 82f82f6 commit 1410533

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

pkg/config/runtime_config.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package config
22

33
import (
4+
"crypto/tls"
45
"time"
56

67
"github.com/spf13/pflag"
@@ -26,6 +27,7 @@ const (
2627
flagWebhookCertDir = "webhook-cert-dir"
2728
flagWebhookCertName = "webhook-cert-file"
2829
flagWebhookKeyName = "webhook-key-file"
30+
flagWebhookDsibleHTTP2 = "webhook-disable-http2"
2931

3032
defaultKubeconfig = ""
3133
defaultLeaderElectionID = "aws-load-balancer-controller-leader"
@@ -40,10 +42,11 @@ const (
4042
defaultQPS = 1e6
4143
// High enough Burst to fit all expected use cases. Burst=0 is not set here, because
4244
// client code is overriding it.
43-
defaultBurst = 1e6
44-
defaultWebhookCertDir = ""
45-
defaultWebhookCertName = ""
46-
defaultWebhookKeyName = ""
45+
defaultBurst = 1e6
46+
defaultWebhookCertDir = ""
47+
defaultWebhookCertName = ""
48+
defaultWebhookKeyName = ""
49+
defaultWebhookDisableHTTP2 = false
4750
)
4851

4952
// RuntimeConfig stores the configuration for the controller-runtime
@@ -61,6 +64,7 @@ type RuntimeConfig struct {
6164
WebhookCertDir string
6265
WebhookCertName string
6366
WebhookKeyName string
67+
WebhookDisableHTTP2 bool
6468
}
6569

6670
// BindFlags binds the command line flags to the fields in the config object
@@ -87,6 +91,7 @@ func (c *RuntimeConfig) BindFlags(fs *pflag.FlagSet) {
8791
fs.StringVar(&c.WebhookCertDir, flagWebhookCertDir, defaultWebhookCertDir, "WebhookCertDir is the directory that contains the webhook server key and certificate.")
8892
fs.StringVar(&c.WebhookCertName, flagWebhookCertName, defaultWebhookCertName, "WebhookCertName is the webhook server certificate name.")
8993
fs.StringVar(&c.WebhookKeyName, flagWebhookKeyName, defaultWebhookKeyName, "WebhookKeyName is the webhook server key name.")
94+
fs.BoolVar(&c.WebhookDisableHTTP2, flagWebhookDsibleHTTP2, defaultWebhookDisableHTTP2, "WebhookDisableHTTP2 disables HTTP2 for the webhook server.")
9095

9196
}
9297

@@ -131,5 +136,12 @@ func BuildRuntimeOptions(rtCfg RuntimeConfig, scheme *runtime.Scheme) ctrl.Optio
131136
func ConfigureWebhookServer(rtCfg RuntimeConfig, mgr ctrl.Manager) {
132137
mgr.GetWebhookServer().CertName = rtCfg.WebhookCertName
133138
mgr.GetWebhookServer().KeyName = rtCfg.WebhookKeyName
134-
mgr.GetWebhookServer().TLSMinVersion = "1.2"
139+
mgr.GetWebhookServer().TLSOpts = []func(config *tls.Config){
140+
func(config *tls.Config) {
141+
config.MinVersion = tls.VersionTLS12
142+
if rtCfg.WebhookDisableHTTP2 {
143+
config.NextProtos = []string{"http/1.1"}
144+
}
145+
},
146+
}
135147
}

0 commit comments

Comments
 (0)