Skip to content

Commit 725bff6

Browse files
authored
use node ip as source when accessing service VIP's from the node (#433)
1 parent 359ab1d commit 725bff6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pkg/controllers/proxy/network_services_controller.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ const (
5555
)
5656

5757
var (
58-
h *ipvs.Handle
58+
h *ipvs.Handle
59+
NodeIP net.IP
5960
)
6061

6162
type ipvsCalls interface {
@@ -111,6 +112,14 @@ func (ln *linuxNetworking) ipAddrAdd(iface netlink.Link, ip string) error {
111112
naddr.IPNet.IP.String(), err.Error())
112113
return err
113114
}
115+
116+
// TODO: netlink.RouteReplace which is replacement for below command is not working as expected. Call succeeds but
117+
// route is not replaced. For now do it with command.
118+
out, err := exec.Command("ip", "route", "replace", "local", ip, "dev", "kube-dummy-if", "table", "local", "proto", "kernel", "scope", "host", "src",
119+
NodeIP.String(), "table", "local").CombinedOutput()
120+
if err != nil {
121+
glog.Errorf("Failed to replace route to service VIP %s configured on kube-dummy-if. Error: %v, Output: %v", ip, err, out)
122+
}
114123
return nil
115124
}
116125
func (ln *linuxNetworking) ipvsGetServices() ([]*ipvs.Service, error) {
@@ -1891,11 +1900,11 @@ func NewNetworkServicesController(clientset kubernetes.Interface,
18911900
}
18921901

18931902
nsc.nodeHostName = node.Name
1894-
nodeIP, err := utils.GetNodeIP(node)
1903+
NodeIP, err = utils.GetNodeIP(node)
18951904
if err != nil {
18961905
return nil, err
18971906
}
1898-
nsc.nodeIP = nodeIP
1907+
nsc.nodeIP = NodeIP
18991908

19001909
nsc.podLister = podInformer.GetIndexer()
19011910

0 commit comments

Comments
 (0)