Skip to content

Commit f0b0b5e

Browse files
authored
Rapid reset scaffold remediation (#54)
Signed-off-by: Catherine Chan-Tse <[email protected]>
1 parent 422d542 commit f0b0b5e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

internal/ansible/flags/flag.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
package flags
1616

1717
import (
18+
"crypto/tls"
1819
"runtime"
1920
"time"
2021

2122
"github.com/spf13/pflag"
2223
"k8s.io/client-go/tools/leaderelection/resourcelock"
2324
"sigs.k8s.io/controller-runtime/pkg/manager"
25+
"sigs.k8s.io/controller-runtime/pkg/webhook"
2426
)
2527

2628
// Flags - Options to be used by an ansible operator
@@ -44,6 +46,8 @@ type Flags struct {
4446
AnsibleArgs string
4547
AnsibleLogEvents string
4648
ProxyPort int
49+
EnableHTTP2 bool
50+
SecureMetrics bool
4751

4852
// Path to a controller-runtime componentconfig file.
4953
// If this is empty, use default values.
@@ -197,6 +201,17 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
197201
8888,
198202
"Ansible proxy server port. Defaults to 8888.",
199203
)
204+
flagSet.BoolVar(&f.EnableHTTP2,
205+
"enable-http2",
206+
false,
207+
"enables HTTP/2 on the webhook and metrics servers",
208+
)
209+
210+
flagSet.BoolVar(&f.SecureMetrics,
211+
"metrics-secure",
212+
false,
213+
"enables secure serving of the metrics endpoint",
214+
)
200215
}
201216

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

259+
disableHTTP2 := func(c *tls.Config) {
260+
c.NextProtos = []string{"http/1.1"}
261+
}
262+
if !f.EnableHTTP2 {
263+
options.WebhookServer = webhook.NewServer(webhook.Options{
264+
TLSOpts: []func(*tls.Config){disableHTTP2},
265+
})
266+
options.Metrics.TLSOpts = append(options.Metrics.TLSOpts, disableHTTP2)
267+
}
268+
options.Metrics.SecureServing = f.SecureMetrics
244269
return options
245270
}

0 commit comments

Comments
 (0)