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

Added flag to disable http/2 #2149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"os"
Expand Down Expand Up @@ -62,6 +63,7 @@ var (
logOptions = logs.NewOptions()
webhookPort int
webhookCertDir string
disableHTTP2 bool

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

fs.BoolVar(&disableHTTP2, "disable-http2", true, "http/2 should be disabled due to its vulnerabilities. More specifically, disabling http/2 will"+
" prevent from being vulnerable to the HTTP/2 Stream Cancellation and Rapid Reset CVEs.")

logsv1.AddFlags(logOptions, fs)
flags.AddManagerOptions(fs, &managerOptions)
}
Expand Down Expand Up @@ -199,6 +204,15 @@ func main() {
}
}

if disableHTTP2 {
metricsOptions.TLSOpts = append(metricsOptions.TLSOpts, func(c *tls.Config) {
setupLog.Info("disabling http/2")
c.NextProtos = []string{"http/1.1"}
})
} else {
setupLog.Info("WARNING: It is not recommended to enable http/2 due to https://github.com/kubernetes/kubernetes/issues/121197")
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
LeaderElection: enableLeaderElection,
Expand Down