mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/kube-vip/kube-vip.git
synced 2026-09-20 08:03:47 +08:00
added zebra integration and its configuration
Signed-off-by: mushrushu <mushrushu@outlook.com>
This commit is contained in:
@@ -93,6 +93,11 @@ func init() {
|
|||||||
kubeVipCmd.PersistentFlags().StringSliceVar(&initConfig.BGPPeers, "bgppeers", []string{}, "Comma separated BGP Peer, format: address:as:password:multihop")
|
kubeVipCmd.PersistentFlags().StringSliceVar(&initConfig.BGPPeers, "bgppeers", []string{}, "Comma separated BGP Peer, format: address:as:password:multihop")
|
||||||
kubeVipCmd.PersistentFlags().StringVar(&initConfig.Annotations, "annotations", "", "Set Node annotations prefix for parsing")
|
kubeVipCmd.PersistentFlags().StringVar(&initConfig.Annotations, "annotations", "", "Set Node annotations prefix for parsing")
|
||||||
|
|
||||||
|
kubeVipCmd.PersistentFlags().BoolVar(&initConfig.BGPConfig.Zebra.Enabled, "zebra", false, "This will enable Zebra support within kube-vip")
|
||||||
|
kubeVipCmd.PersistentFlags().StringVar(&initConfig.BGPConfig.Zebra.Url, "zebraUrl", "unix:/var/run/frr/zserv.api", "Path to the unix domain socket for connecting to Zebra daemon")
|
||||||
|
kubeVipCmd.PersistentFlags().Uint32Var(&initConfig.BGPConfig.Zebra.Version, "zebraVersion", 6, "Zebra API Version")
|
||||||
|
kubeVipCmd.PersistentFlags().StringVar(&initConfig.BGPConfig.Zebra.SoftwareName, "zebraSoftwareName", "frr8.3", "Software Name for Zebra")
|
||||||
|
|
||||||
// Namespace for kube-vip
|
// Namespace for kube-vip
|
||||||
kubeVipCmd.PersistentFlags().StringVarP(&initConfig.Namespace, "namespace", "n", "kube-system", "The namespace for the configmap defined within the cluster")
|
kubeVipCmd.PersistentFlags().StringVarP(&initConfig.Namespace, "namespace", "n", "kube-system", "The namespace for the configmap defined within the cluster")
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,17 @@ func NewBGPServer(c *Config, peerStateChangeCallback func(*api.WatchEventRespons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Zebra.Enabled {
|
||||||
|
if err = b.s.EnableZebra(context.Background(), &api.EnableZebraRequest{
|
||||||
|
Url: c.Zebra.Url,
|
||||||
|
Version: c.Zebra.Version,
|
||||||
|
SoftwareName: c.Zebra.SoftwareName,
|
||||||
|
}); err != nil {
|
||||||
|
log.Error("failed to enable zebra:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,16 @@ type Config struct {
|
|||||||
KeepaliveInterval uint64
|
KeepaliveInterval uint64
|
||||||
|
|
||||||
Peers []Peer
|
Peers []Peer
|
||||||
|
|
||||||
|
Zebra ZebraConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// Defines Zebra connection configuration. More on the topic - https://github.com/osrg/gobgp/blob/master/docs/sources/zebra.md#configuration
|
||||||
|
type ZebraConfig struct {
|
||||||
|
Enabled bool
|
||||||
|
Url string
|
||||||
|
Version uint32
|
||||||
|
SoftwareName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server manages a server object
|
// Server manages a server object
|
||||||
|
|||||||
@@ -500,6 +500,34 @@ func ParseEnvironment(c *Config) error {
|
|||||||
c.BGPConfig.KeepaliveInterval = u64
|
c.BGPConfig.KeepaliveInterval = u64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env = os.Getenv(zebraEnable)
|
||||||
|
if env != "" {
|
||||||
|
result, err := strconv.ParseBool(env)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.BGPConfig.Zebra.Enabled = result
|
||||||
|
}
|
||||||
|
|
||||||
|
env = os.Getenv(zebraUrl)
|
||||||
|
if env != "" {
|
||||||
|
c.BGPConfig.Zebra.Url = env
|
||||||
|
}
|
||||||
|
|
||||||
|
env = os.Getenv(zebraVersion)
|
||||||
|
if env != "" {
|
||||||
|
u64, err := strconv.ParseUint(env, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.BGPConfig.Zebra.Version = uint32(u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
env = os.Getenv(zebraSoftwareName)
|
||||||
|
if env != "" {
|
||||||
|
c.BGPConfig.Zebra.SoftwareName = env
|
||||||
|
}
|
||||||
|
|
||||||
// Enable the load-balancer
|
// Enable the load-balancer
|
||||||
env = os.Getenv(lbEnable)
|
env = os.Getenv(lbEnable)
|
||||||
if env != "" {
|
if env != "" {
|
||||||
|
|||||||
@@ -110,6 +110,15 @@ const (
|
|||||||
// bgpKeepaliveInterval defines bgp timers keepalive interval
|
// bgpKeepaliveInterval defines bgp timers keepalive interval
|
||||||
bgpKeepaliveInterval = "bgp_keepalive_interval"
|
bgpKeepaliveInterval = "bgp_keepalive_interval"
|
||||||
|
|
||||||
|
// zebraEnable defines if Zebra integraton should be enabled
|
||||||
|
zebraEnable = "zebra_enable"
|
||||||
|
// zebraUrl specifies path to the unix domain socket for connecting to Zebra daemon
|
||||||
|
zebraUrl = "zebra_url"
|
||||||
|
// zebraVersion specifies Zebra API Version
|
||||||
|
zebraVersion = "zebra_version"
|
||||||
|
// zebraSoftwareName specifies Software Name for Zebra
|
||||||
|
zebraSoftwareName = "zebra_software_name"
|
||||||
|
|
||||||
// mpbgpNexthop defines MPBGP mode
|
// mpbgpNexthop defines MPBGP mode
|
||||||
mpbgpNexthop = "mpbgp_nexthop"
|
mpbgpNexthop = "mpbgp_nexthop"
|
||||||
// mpbgpIPv4 defines fixed IPv4 to be used with MPBGP
|
// mpbgpIPv4 defines fixed IPv4 to be used with MPBGP
|
||||||
|
|||||||
Reference in New Issue
Block a user