Skip to content

Commit

Permalink
use node ip as source when accessing service VIP's from the node (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-reddy committed May 12, 2018
1 parent 359ab1d commit 725bff6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/controllers/proxy/network_services_controller.go
Expand Up @@ -55,7 +55,8 @@ const (
)

var (
h *ipvs.Handle
h *ipvs.Handle
NodeIP net.IP
)

type ipvsCalls interface {
Expand Down Expand Up @@ -111,6 +112,14 @@ func (ln *linuxNetworking) ipAddrAdd(iface netlink.Link, ip string) error {
naddr.IPNet.IP.String(), err.Error())
return err
}

// TODO: netlink.RouteReplace which is replacement for below command is not working as expected. Call succeeds but
// route is not replaced. For now do it with command.
out, err := exec.Command("ip", "route", "replace", "local", ip, "dev", "kube-dummy-if", "table", "local", "proto", "kernel", "scope", "host", "src",
NodeIP.String(), "table", "local").CombinedOutput()
if err != nil {
glog.Errorf("Failed to replace route to service VIP %s configured on kube-dummy-if. Error: %v, Output: %v", ip, err, out)
}
return nil
}
func (ln *linuxNetworking) ipvsGetServices() ([]*ipvs.Service, error) {
Expand Down Expand Up @@ -1891,11 +1900,11 @@ func NewNetworkServicesController(clientset kubernetes.Interface,
}

nsc.nodeHostName = node.Name
nodeIP, err := utils.GetNodeIP(node)
NodeIP, err = utils.GetNodeIP(node)
if err != nil {
return nil, err
}
nsc.nodeIP = nodeIP
nsc.nodeIP = NodeIP

nsc.podLister = podInformer.GetIndexer()

Expand Down

0 comments on commit 725bff6

Please sign in to comment.