Skip to content

Commit cc6dc28

Browse files
Added flag to disable http/2
1 parent ab4d5c8 commit cc6dc28

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.go

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919

2020
import (
2121
"context"
22+
"crypto/tls"
2223
"flag"
2324
"fmt"
2425
"os"
@@ -62,6 +63,7 @@ var (
6263
logOptions = logs.NewOptions()
6364
webhookPort int
6465
webhookCertDir string
66+
disableHTTP2 bool
6567

6668
scheme = runtime.NewScheme()
6769
setupLog = ctrl.Log.WithName("setup")
@@ -130,6 +132,9 @@ func initFlags(fs *pflag.FlagSet) {
130132
fs.StringVar(&webhookCertDir, "webhook-cert-dir", "/tmp/k8s-webhook-server/serving-certs/",
131133
"The webhook certificate directory, where the server should find the TLS certificate and key.")
132134

135+
fs.BoolVar(&disableHTTP2, "disable-http2", true, "http/2 should be disabled due to its vulnerabilities. More specifically, disabling http/2 will"+
136+
" prevent from being vulnerable to the HTTP/2 Stream Cancellation and Rapid Reset CVEs.")
137+
133138
logsv1.AddFlags(logOptions, fs)
134139
flags.AddManagerOptions(fs, &managerOptions)
135140
}
@@ -199,6 +204,15 @@ func main() {
199204
}
200205
}
201206

207+
if disableHTTP2 {
208+
metricsOptions.TLSOpts = append(metricsOptions.TLSOpts, func(c *tls.Config) {
209+
setupLog.Info("disabling http/2")
210+
c.NextProtos = []string{"http/1.1"}
211+
})
212+
} else {
213+
setupLog.Info("WARNING: It is not recommended to enable http/2 due to https://github.com/kubernetes/kubernetes/issues/121197")
214+
}
215+
202216
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
203217
Scheme: scheme,
204218
LeaderElection: enableLeaderElection,

0 commit comments

Comments
 (0)