middleware/kubernetes: cleanup (#818)
Drop the interfaceAddr interfaces and just use a function. Cleanup all fallout from that. Remove the use of global variables and cleanup the tests a bit.
This commit is contained in:
parent
8ad8c75ab4
commit
2c0fc3182c
8 changed files with 25 additions and 53 deletions
|
@ -13,10 +13,6 @@ type Federation struct {
|
|||
zone string
|
||||
}
|
||||
|
||||
var localNodeName string
|
||||
var federationZone string
|
||||
var federationRegion string
|
||||
|
||||
const (
|
||||
// TODO: Do not hardcode these labels. Pull them out of the API instead.
|
||||
//
|
||||
|
@ -80,21 +76,18 @@ func (k *Kubernetes) federationCNAMERecord(r recordRequest) msg.Service {
|
|||
}
|
||||
|
||||
func (k *Kubernetes) localNodeName() string {
|
||||
if localNodeName != "" {
|
||||
return localNodeName
|
||||
}
|
||||
localIP := k.localPodIP()
|
||||
localIP := k.interfaceAddrsFunc()
|
||||
if localIP == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Find endpoint matching localIP
|
||||
endpointsList := k.APIConn.EndpointsList()
|
||||
for _, ep := range endpointsList.Items {
|
||||
for _, eps := range ep.Subsets {
|
||||
for _, addr := range eps.Addresses {
|
||||
if localIP.Equal(net.ParseIP(addr.IP)) {
|
||||
localNodeName = *addr.NodeName
|
||||
return localNodeName
|
||||
return *addr.NodeName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue