added netbox allocator
This commit is contained in:
parent
fef86deac8
commit
cef74df3e8
10 changed files with 195 additions and 53 deletions
|
|
@ -15,6 +15,14 @@ import (
|
|||
)
|
||||
|
||||
func NewLBController(cfg *config.Config, srv *api.Server, log logr.Logger) (callbacks cluster.Callbacks, err error) {
|
||||
var fo *vip.Network
|
||||
if cfg.Failover != nil {
|
||||
fo, err = vip.NewNetwork(cfg.Failover.Interface)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
n, err := vip.NewNetworkWithLabel(cfg.VIP.Interface, cfg.VIP.Label)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -57,6 +65,9 @@ func NewLBController(cfg *config.Config, srv *api.Server, log logr.Logger) (call
|
|||
return
|
||||
}
|
||||
log.Info("leading", "id", cc.ID())
|
||||
if cfg.Failover != nil {
|
||||
addIPs(log, fo, []string{cfg.Failover.IP})
|
||||
}
|
||||
ips, err := db.GetDeletedIPs()
|
||||
if err != nil && err != cluster.ErrPrefixNotFound {
|
||||
log.Error(err, "error reading deleted ips list")
|
||||
|
|
@ -150,6 +161,9 @@ func NewLBController(cfg *config.Config, srv *api.Server, log logr.Logger) (call
|
|||
}
|
||||
},
|
||||
Cleanup: func(ctx context.Context, cc cluster.CallbackContext) {
|
||||
if cfg.Failover != nil {
|
||||
deleteIPs(log, fo, fo.GetIPs())
|
||||
}
|
||||
deleteIPs(log, n, n.GetIPs())
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue