Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for loadbalancer-ips #1

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ options:
type: int
default: 600
description: Timeout in seconds for reading a response from proxy server.
loadbalancer-ips:
type: string
description: |
Space seperated list of IP addresses of loadbalancers in front of control plane.
A common case for this is virtual IP addresses that are floated in front of the
kubeapi-load-balancer charm. The workers will alternate IP addresses from this
list to distribute load. If you have 2 IPs and 4 workers, each IP will be used
by 2 workers.
default: ""
41 changes: 27 additions & 14 deletions reactive/load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,18 @@ def request_server_certificates():
get_ingress_address(website.endpoint_name),
socket.gethostname(),
]
hacluster = endpoint_from_flag('ha.connected')
if hacluster:
vips = hookenv.config('ha-cluster-vip').split()
dns_record = hookenv.config('ha-cluster-dns')
if vips:
sans.extend(vips)
elif dns_record:
sans.append(dns_record)
forced_lb_ips = hookenv.config('loadbalancer-ips').split()
if forced_lb_ips:
sans.extend(forced_lb_ips)
else:
hacluster = endpoint_from_flag('ha.connected')
if hacluster:
vips = hookenv.config('ha-cluster-vip').split()
dns_record = hookenv.config('ha-cluster-dns')
if vips:
sans.extend(vips)
elif dns_record:
sans.append(dns_record)

# maybe they have extra names they want as SANs
extra_sans = hookenv.config('extra_sans')
Expand Down Expand Up @@ -199,19 +203,25 @@ def provide_application_details():
kubernetes API '''
website = endpoint_from_flag('website.available')
hacluster = endpoint_from_flag('ha.connected')
if hacluster:
forced_lb_ips = hookenv.config('loadbalancer-ips').split()
address = None
if forced_lb_ips:
address = forced_lb_ips
elif hacluster:
# in the hacluster world, we dump the vip or the dns
# on every unit's data. This is because the
# kubernetes-master charm just grabs the first
# one it sees and uses that ip/dns.
vips = hookenv.config('ha-cluster-vip').split()
dns_record = hookenv.config('ha-cluster-dns')
if vips:
website.configure(hookenv.config('port'), vips, vips)
address = vips
elif dns_record:
website.configure(hookenv.config('port'), dns_record, dns_record)
else:
website.configure(port=hookenv.config('port'))
address = dns_record
if address:
website.configure(port=hookenv.config('port'),
private_address=address,
hostname=address)
else:
website.configure(port=hookenv.config('port'))

Expand All @@ -222,7 +232,10 @@ def provide_loadbalancing():
the subordinates can get the public address of this loadbalancer.'''
loadbalancer = endpoint_from_flag('loadbalancer.available')
hacluster = endpoint_from_flag('ha.connected')
if hacluster:
forced_lb_ips = hookenv.config('loadbalancer-ips').split()
if forced_lb_ips:
address = forced_lb_ips
elif hacluster:
# in the hacluster world, we dump the vip or the dns
# on every unit's data. This is because the
# kubernetes-master charm just grabs the first
Expand Down