Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #29 from mmiller1/master
Browse files Browse the repository at this point in the history
add flag to set the host interface to use
  • Loading branch information
aledbf authored Dec 25, 2017
2 parents fd228e4 + 1a032a0 commit 75d1d0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions pkg/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ var (
`The keepalived VRID (Virtual Router Identifier, between 0 and 255 as per
RFC-5798), which must be different for every Virtual Router (ie. every
keepalived sets) running on the same network.`)

iface = flags.String("iface", "", `network interface to listen on. If undefined, the nodes
default interface will be used instead`)
)

func main() {
Expand Down Expand Up @@ -118,14 +121,13 @@ func main() {
if *proxyMode {
copyHaproxyCfg()
}

kubeClient, err := createApiserverClient(*apiserverHost, *kubeConfigFile)
if err != nil {
handleFatalInitError(err)
}

glog.Info("starting LVS configuration")
ipvsc := controller.NewIPVSController(kubeClient, *watchNamespace, *useUnicast, *configMapName, *vrid, *proxyMode)
ipvsc := controller.NewIPVSController(kubeClient, *watchNamespace, *useUnicast, *configMapName, *vrid, *proxyMode, *iface)

ipvsc.Start()
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/keepalived.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (k *keepalived) WriteCfg(svcs []vip) error {
conf["priority"] = k.priority
conf["useUnicast"] = k.useUnicast
conf["vrid"] = k.vrid
conf["iface"] = k.iface
conf["proxyMode"] = k.proxyMode
conf["vipIsEmpty"] = len(k.vips) == 0

Expand Down
9 changes: 6 additions & 3 deletions pkg/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (ipvsc *ipvsControllerController) Stop() error {
}

// NewIPVSController creates a new controller from the given config.
func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUnicast bool, configMapName string, vrid int, proxyMode bool) *ipvsControllerController {
func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUnicast bool, configMapName string, vrid int, proxyMode bool, iface string) *ipvsControllerController {
ipvsc := ipvsControllerController{
client: kubeClient,
reloadRateLimiter: flowcontrol.NewTokenBucketRateLimiter(0.5, 1),
Expand All @@ -365,15 +365,18 @@ func NewIPVSController(kubeClient *kubernetes.Clientset, namespace string, useUn
if err != nil {
glog.Fatalf("Error getting local IP from nodes in the cluster: %v", err)
}

neighbors := getNodeNeighbors(nodeInfo, clusterNodes)

if iface == "" {
iface = nodeInfo.iface
glog.Info("No interface was provided, proceeding with the node's default: ", iface)
}
execer := utilexec.New()
dbus := utildbus.New()
iptInterface := utiliptables.New(execer, dbus, utiliptables.ProtocolIpv4)

ipvsc.keepalived = &keepalived{
iface: nodeInfo.iface,
iface: iface,
ip: nodeInfo.ip,
netmask: nodeInfo.netmask,
nodes: clusterNodes,
Expand Down

0 comments on commit 75d1d0a

Please sign in to comment.