Skip to content

Commit ca7731e

Browse files
committed
Change priority order for getting node IPs
Internal IP being the first.
1 parent 3c5e6cf commit ca7731e

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Service-loadbalancer support for L4 is very limited. The binding-port needs to b
2525

2626
### Software Loadbalancer using keepalived and nginx
2727

28-
1. First we need to create the loadbalancer controller.
28+
1. First we need to create the loadbalancer controller. Make sure you provide the VIP allocation range. They must be reachable from outside. (Usually they are VIPs on the same subnet as the node network.)
2929
```
3030
$ kubectl create -f examples/kube-loadbalancer-rc.yaml
3131
```

loadbalancer-daemon/controllers/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func getNodeInterface(kubeClient *client.Client) string {
232232
}
233233
iface := interfaceByIP(*nodeIP)
234234
if iface == "" {
235-
glog.Fatalf("Cannot find interface for IP: %v", nodeIP)
235+
glog.Fatalf("Cannot find interface for IP: %v", *nodeIP)
236236
}
237237
return iface
238238
}

loadbalancer/utils/utils.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,26 @@ func MapKeys(m map[string]string) []string {
127127
}
128128

129129
// GetNodeHostIP returns the provided node's IP, based on the priority:
130-
// 1. NodeExternalIP
130+
// 1. NodeInternalIP
131131
// 2. NodeLegacyHostIP
132-
// 3. NodeInternalIP
132+
// 3. NodeExternalIP
133+
133134
func GetNodeHostIP(node api.Node) (*string, error) {
134135
addresses := node.Status.Addresses
135136
addressMap := make(map[api.NodeAddressType][]api.NodeAddress)
136137
for i := range addresses {
137138
addressMap[addresses[i].Type] = append(addressMap[addresses[i].Type], addresses[i])
138139
}
139-
if addresses, ok := addressMap[api.NodeExternalIP]; ok {
140+
if addresses, ok := addressMap[api.NodeInternalIP]; ok {
140141
return &addresses[0].Address, nil
141142
}
142143
if addresses, ok := addressMap[api.NodeLegacyHostIP]; ok {
143144
return &addresses[0].Address, nil
144145
}
145-
if addresses, ok := addressMap[api.NodeInternalIP]; ok {
146+
if addresses, ok := addressMap[api.NodeExternalIP]; ok {
146147
return &addresses[0].Address, nil
147148
}
149+
148150
return nil, fmt.Errorf("Host IP unknown; known addresses: %v", addresses)
149151
}
150152

0 commit comments

Comments
 (0)