-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
69 lines (59 loc) · 1.85 KB
/
Copy pathmain.go
File metadata and controls
69 lines (59 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"os"
"time"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/client"
netcupv1alpha1 "github.com/digilolnet/netcup-failover-controller/api/v1alpha1"
"github.com/digilolnet/netcup-failover-controller/internal/controller"
"github.com/digilolnet/netcup-failover-controller/internal/netcup"
)
var scheme = runtime.NewScheme()
func init() {
utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(netcupv1alpha1.AddToScheme(scheme))
}
func main() {
ctrl.SetLogger(zap.New())
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
LeaderElection: true,
LeaderElectionID: "netcup-failover-controller.digilol.net",
HealthProbeBindAddress: ":8081",
Client: client.Options{
Cache: &client.CacheOptions{
DisableFor: []client.Object{&corev1.Secret{}},
},
},
})
if err != nil {
ctrl.Log.Error(err, "failed to create manager")
os.Exit(1)
}
if err := (&controller.FailoverIPReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
SOAP: netcup.NewSOAPClient(),
RetryInterval: 3 * time.Second,
}).SetupWithManager(mgr); err != nil {
ctrl.Log.Error(err, "failed to setup controller")
os.Exit(1)
}
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
ctrl.Log.Error(err, "failed to add healthz check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
ctrl.Log.Error(err, "failed to add readyz check")
os.Exit(1)
}
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
ctrl.Log.Error(err, "failed to run manager")
os.Exit(1)
}
}