Skip to content

Commit

Permalink
[manager] Update manager initialisation for CR update
Browse files Browse the repository at this point in the history
This change updates the manager intialisation to comply with the new
controller-runtime schema.

Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Feb 14, 2024
1 parent abd484f commit 5546f1e
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"

metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

metal3v1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"

Expand Down Expand Up @@ -81,23 +84,18 @@ func main() {
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "dedc2245.openstack.org",
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
// when the Manager ends. This requires the binary to immediately end when the
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
// speeds up voluntary leader transitions as the new leader don't have to wait
// LeaseDuration time first.
//
// In the default scaffold provided, the program ends immediately after
// the manager stops, so would be fine to enable this option. However,
// if you are doing or is intended to do any operation such as perform cleanups
// after the manager stops then its usage might be unsafe.
// LeaderElectionReleaseOnCancel: true,
LeaderElectionID: "c8c223a1.openstack.org",
WebhookServer: webhook.NewServer(
webhook.Options{
Port: 9443,
TLSOpts: []func(config *tls.Config){disableHTTP2},
}),
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down Expand Up @@ -141,9 +139,6 @@ func main() {
//
checker := healthz.Ping
if strings.ToLower(os.Getenv("ENABLE_WEBHOOKS")) != "false" {
// overriding the default values
srv := mgr.GetWebhookServer()
srv.TLSOpts = []func(config *tls.Config){disableHTTP2}

if err = (&baremetalv1beta1.OpenStackBaremetalSet{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "OpenStackBaremetalSet")
Expand Down

0 comments on commit 5546f1e

Please sign in to comment.