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

disable http2 for metrics and webhooks by default #356

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"crypto/tls"
"flag"
"os"
"time"
Expand Down Expand Up @@ -64,13 +65,15 @@ func main() {
var enableLeaderElection bool
var probeAddr string
var migrateFromVMware bool
var enableHTTP2 bool
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.BoolVar(&migrateFromVMware, "migrate-from-vmware", false,
"Enable migration from the VMware implementation.")
flag.BoolVar(&enableHTTP2, "enable-http2", false, "Enable HTTP2 for the metrics and webhook servers")
opts := zap.Options{
Development: true,
}
Expand All @@ -79,14 +82,26 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

disableHTTP2 := func(t *tls.Config) {
if enableHTTP2 {
t.NextProtos = []string{"http/1.1"}
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddr,
TLSOpts: []func(*tls.Config){
disableHTTP2,
},
},
WebhookServer: &webhook.DefaultServer{
Options: webhook.Options{
Port: 9443,
TLSOpts: []func(*tls.Config){
disableHTTP2,
},
},
},
Cache: cache.Options{
Expand Down