pkg/mesh: ignore CNI IP from private IPs

We need to ignore the CNI IP address from the searched IPs, as this will
not be a routable IP address.
This commit is contained in:
Lucas Servén Marín
2019-05-13 17:35:05 +02:00
parent 8ed1b549d1
commit d7ad946ff4
3 changed files with 60 additions and 9 deletions

View File

@@ -25,8 +25,24 @@ import (
"github.com/containernetworking/cni/pkg/types"
ipamallocator "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
"github.com/go-kit/kit/log/level"
"github.com/vishvananda/netlink"
)
const cniDeviceName = "kube-bridge"
// Try to get the CNI device index.
// Return 0 if not found and any error encountered.
func cniDeviceIndex() (int, error) {
i, err := netlink.LinkByName(cniDeviceName)
if _, ok := err.(netlink.LinkNotFoundError); ok {
return 0, nil
}
if err != nil {
return 0, err
}
return i.Attrs().Index, nil
}
// updateCNIConfig will try to update the local node's CNI config.
func (m *Mesh) updateCNIConfig() {
m.mu.Lock()