Skip to content

Commit e87a273

Browse files
Added flag to disable http/2
1 parent 353b235 commit e87a273

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: main.go

+13
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"
@@ -64,6 +65,7 @@ var (
6465
webhookPort int
6566
webhookCertDir string
6667
watchFilterValue string
68+
disableHTTP2 bool
6769

6870
scheme = runtime.NewScheme()
6971
setupLog = ctrl.Log.WithName("setup")
@@ -134,6 +136,8 @@ func initFlags(fs *pflag.FlagSet) {
134136

135137
fs.StringVar(&watchFilterValue, "watch-filter", "",
136138
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", capiv1beta1.WatchLabel))
139+
fs.BoolVar(&disableHTTP2, "disable-http2", true, "http/2 should be disabled due to its vulnerabilities. More specifically, disabling http/2 will"+
140+
" prevent from being vulnerable to the HTTP/2 Stream Cancellation and Rapid Reset CVEs.")
137141

138142
logsv1.AddFlags(logOptions, fs)
139143
flags.AddManagerOptions(fs, &managerOptions)
@@ -200,6 +204,15 @@ func main() {
200204
}
201205
}
202206

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+
203216
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
204217
Scheme: scheme,
205218
LeaderElection: enableLeaderElection,

0 commit comments

Comments
 (0)