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

Rapid reset scaffold remediation #54

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
25 changes: 25 additions & 0 deletions internal/ansible/flags/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
package flags

import (
"crypto/tls"
"runtime"
"time"

"github.com/spf13/pflag"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// Flags - Options to be used by an ansible operator
Expand All @@ -44,6 +46,8 @@ type Flags struct {
AnsibleArgs string
AnsibleLogEvents string
ProxyPort int
EnableHTTP2 bool
SecureMetrics bool

// Path to a controller-runtime componentconfig file.
// If this is empty, use default values.
Expand Down Expand Up @@ -197,6 +201,17 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
8888,
"Ansible proxy server port. Defaults to 8888.",
)
flagSet.BoolVar(&f.EnableHTTP2,
"enable-http2",
false,
"enables HTTP/2 on the webhook and metrics servers",
)

flagSet.BoolVar(&f.SecureMetrics,
"metrics-secure",
false,
"enables secure serving of the metrics endpoint",
)
}

// ToManagerOptions uses the flag set in f to configure options.
Expand Down Expand Up @@ -241,5 +256,15 @@ func (f *Flags) ToManagerOptions(options manager.Options) manager.Options {
options.GracefulShutdownTimeout = &f.GracefulShutdownTimeout
}

disableHTTP2 := func(c *tls.Config) {
c.NextProtos = []string{"http/1.1"}
}
if !f.EnableHTTP2 {
options.WebhookServer = webhook.NewServer(webhook.Options{
TLSOpts: []func(*tls.Config){disableHTTP2},
})
options.Metrics.TLSOpts = append(options.Metrics.TLSOpts, disableHTTP2)
}
options.Metrics.SecureServing = f.SecureMetrics
return options
}