Autodetect OWN_PRIVATE_API_URL
OWN_PRIVATE_API_URL environment variable is often causing issues in Omnibus setup because it's difficult to configure it (in Omnibus) for multi-host installations of kas.
Proposal
Introduce new mode of operations:
- See if
OWN_PRIVATE_API_URLis set. If specified, use it. - Look for
OWN_PRIVATE_API_CIDR. If it's set, treat it as CIDR. This can be parsed usingnet.ParseCIDR(). After successful parsing, look at the available network interfaces. Use the address that matches the CIDR as the own IP address. Report error if multiple addresses match. - Look for
OWN_PRIVATE_API_SCHEME. If specified, use it (grpc/grpcs). If not, usegrpc. - Look for
OWN_PRIVATE_API_PORT. If specified, use it. - If
OWN_PRIVATE_API_CIDRis not set, look at the listen address for the private API endpoint. Use the exact IP+port provided unless it's a wildcard "listen-on-all-interfaces" address (0.0.0.0or::).OWN_PRIVATE_API_PORTis ignored in this case. - If all of the above fails, abort the program.
Edited by Mikhail Mazurskiy