Update kubeapi-load-balancer/lib/charms/layer/kubernetes_common.py

This commit is contained in:
Ares 2023-06-28 14:48:26 +00:00
parent bb2340904f
commit cde295d64c
1 changed files with 11 additions and 0 deletions

View File

@ -170,6 +170,17 @@ def get_ingress_address(endpoint_name, ignore_addresses=None):
# doesn't support spaces, so just return the private address
return hookenv.unit_get("private-address")
excluded_ips = []
excluded_interfaces = ["vxlan", "kube", "wg", "docker", "cali", "virbr", "cni", "flannel"]
for addr in network_info["bind-addresses"]:
for prefix in excluded_interfaces:
if addr["interface-name"].startswith(prefix):
for ip in addr["addresses"]:
excluded_ips.append(ip["value"])
ingress_addresses = network_info["ingress-addresses"]
network_info["ingress-addresses"] = [ip for ip in ingress_addresses if ip not in excluded_ips]
addresses = network_info["ingress-addresses"]
if ignore_addresses: