def get_api_endpoint(relation=None):
    '\n    Determine the best endpoint for a client to connect to.\n\n    If a relation is given, it will take that into account when choosing an\n    endpoint.\n    '
    endpoints = get_lb_endpoints()
    if endpoints:
        return endpoints[(kubernetes_common.get_unit_number() % len(endpoints))]
    elif relation:
        ingress_address = hookenv.ingress_address(relation.relation_id, hookenv.local_unit())
        return (ingress_address, STANDARD_API_PORT)
    else:
        return (hookenv.unit_public_ip(), STANDARD_API_PORT)
Determine the best endpoint for a client to connect to.

If a relation is given, it will take that into account when choosing an
endpoint.
def get_api_endpoint(relation=None):
    '\n    Determine the best endpoint for a client to connect to.\n\n    If a relation is given, it will take that into account when choosing an\n    endpoint.\n    '
    endpoints = get_lb_endpoints()
    if endpoints:
        return endpoints[(kubernetes_common.get_unit_number() % len(endpoints))]
    elif relation:
        ingress_address = hookenv.ingress_address(relation.relation_id, hookenv.local_unit())
        return (ingress_address, STANDARD_API_PORT)
    else:
        return (hookenv.unit_public_ip(), STANDARD_API_PORT)