Giter Site home page Giter Site logo

Comments (2)

d-uzlov avatar d-uzlov commented on June 19, 2024

Currently kube-vip attempts to handle FQDN hostname cases. For example, here:

// 1. Compare the hostname on the endpoint to the hostname
// 2. Compare the nodename on the endpoint to the hostname
// 3. Drop the FQDN to a shortname and compare to the nodename on the endpoint
// 1. Compare the Hostname first (should be FQDN)
log.Debugf("[%s] processing endpoint [%s]", ep.label, ep.endpoints.Subsets[subset].Addresses[address].IP)
if id == ep.endpoints.Subsets[subset].Addresses[address].Hostname {
log.Debugf("[%s] found local endpoint - address: %s, hostname: %s",
ep.label, ep.endpoints.Subsets[subset].Addresses[address].IP, ep.endpoints.Subsets[subset].Addresses[address].Hostname)
localEndpoints = append(localEndpoints, ep.endpoints.Subsets[subset].Addresses[address].IP)
} else {
// 2. Compare the Nodename (from testing could be FQDN or short)
if ep.endpoints.Subsets[subset].Addresses[address].NodeName != nil {
if id == *ep.endpoints.Subsets[subset].Addresses[address].NodeName {
log.Debugf("[%s] found local endpoint - address: %s, hostname: %s, node: %s",
ep.label, ep.endpoints.Subsets[subset].Addresses[address].IP, ep.endpoints.Subsets[subset].Addresses[address].Hostname,
*ep.endpoints.Subsets[subset].Addresses[address].NodeName)
localEndpoints = append(localEndpoints, ep.endpoints.Subsets[subset].Addresses[address].IP)
} else if shortnameErr == nil && shortname == *ep.endpoints.Subsets[subset].Addresses[address].NodeName {
log.Debugf("[%s] found local endpoint - address: %s, shortname: %s, node: %s",
ep.label, ep.endpoints.Subsets[subset].Addresses[address].IP, shortname, *ep.endpoints.Subsets[subset].Addresses[address].NodeName)
localEndpoints = append(localEndpoints, ep.endpoints.Subsets[subset].Addresses[address].IP)
}
}
}

// 1. Compare the hostname on the endpoint to the hostname
// 2. Compare the nodename on the endpoint to the hostname
// 3. Drop the FQDN to a shortname and compare to the nodename on the endpoint
// 1. Compare the Hostname first (should be FQDN)
log.Debugf("[%s] processing endpoint [%s]", ep.label, ep.endpoints.Endpoints[i].Addresses[j])
if ep.endpoints.Endpoints[i].Hostname != nil && id == *ep.endpoints.Endpoints[i].Hostname {
if *ep.endpoints.Endpoints[i].Conditions.Serving {
log.Debugf("[%s] found endpoint - address: %s, hostname: %s", ep.label, ep.endpoints.Endpoints[i].Addresses[j], *ep.endpoints.Endpoints[i].Hostname)
localEndpoints = append(localEndpoints, ep.endpoints.Endpoints[i].Addresses[j])
}
} else {
// 2. Compare the Nodename (from testing could be FQDN or short)
if ep.endpoints.Endpoints[i].NodeName != nil {
if id == *ep.endpoints.Endpoints[i].NodeName && *ep.endpoints.Endpoints[i].Conditions.Serving {
if ep.endpoints.Endpoints[i].Hostname != nil {
log.Debugf("[%s] found endpoint - address: %s, hostname: %s, node: %s", ep.label, ep.endpoints.Endpoints[i].Addresses[j], *ep.endpoints.Endpoints[i].Hostname, *ep.endpoints.Endpoints[i].NodeName)
} else {
log.Debugf("[%s] found endpoint - address: %s, node: %s", ep.label, ep.endpoints.Endpoints[i].Addresses[j], *ep.endpoints.Endpoints[i].NodeName)
}
localEndpoints = append(localEndpoints, ep.endpoints.Endpoints[i].Addresses[j])
// 3. Compare to shortname
} else if shortnameErr != nil && shortname == *ep.endpoints.Endpoints[i].NodeName && *ep.endpoints.Endpoints[i].Conditions.Serving {
log.Debugf("[%s] found endpoint - address: %s, shortname: %s, node: %s", ep.label, ep.endpoints.Endpoints[i].Addresses[j], shortname, *ep.endpoints.Endpoints[i].NodeName)
localEndpoints = append(localEndpoints, ep.endpoints.Endpoints[i].Addresses[j])
}
}
}

But it still doesn't work because in other places it doesn't:

  1. Here id goes straight into watchEndpoint, which could handle FQDN names but it doesn't because id = os.Hostname() is already a short name)

    id, err := os.Hostname()

    if err = sm.watchEndpoint(activeServiceLoadBalancer[string(svc.UID)], id, svc, &wg, provider); err != nil {

  2. Here hostname := os.Hostname() is a short name, but kubernetes.io/hostname can be set to either FQDN or an arbitrary custom string:

    hostname, err := os.Hostname()

    labelSelector := metav1.LabelSelector{MatchLabels: map[string]string{"kubernetes.io/hostname": hostname}}

from kube-vip.

d-uzlov avatar d-uzlov commented on June 19, 2024

Now that v0.8.0 is released I think we can close this.

from kube-vip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.