Merge pull request #58708 from hyperbolic2346/mwilson/kubeapi-network-spaces

Automatic merge from submit-queue (batch tested with PRs 54242, 58522, 58704, 58708, 58712). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Adding network spaces support for kubeapi-load-balancer.

**What this PR does / why we need it**:
Adding support for juju network spaces to kubeapi-load-balancer charm
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #
https://github.com/juju-solutions/bundle-canonical-kubernetes/issues/406
**Special notes for your reviewer**:

**Release note**:

```release-note
Added support for network spaces in the kubeapi-load-balancer charm
```
This commit is contained in:
Kubernetes Submit Queue 2018-01-23 15:29:46 -08:00 committed by GitHub
commit 36ea7614e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,8 +56,23 @@ apilb_nginx = """/var/log/nginx.*.log {
}"""
@when('certificates.available')
def request_server_certificates(tls):
def get_ingress_address(relation):
try:
network_info = hookenv.network_get(relation.relation_name)
except NotImplementedError:
network_info = []
if network_info and 'ingress-addresses' in network_info:
# just grab the first one for now, maybe be more robust here?
return network_info['ingress-addresses'][0]
else:
# if they don't have ingress-addresses they are running a juju that
# doesn't support spaces, so just return the private address
return hookenv.unit_get('private-address')
@when('certificates.available', 'website.available')
def request_server_certificates(tls, website):
'''Send the data that is required to create a server certificate for
this server.'''
# Use the public ip of this unit as the Common Name for the certificate.
@ -65,7 +80,7 @@ def request_server_certificates(tls):
# Create SANs that the tls layer will add to the server cert.
sans = [
hookenv.unit_public_ip(),
hookenv.unit_private_ip(),
get_ingress_address(website),
socket.gethostname(),
]
# maybe they have extra names they want as SANs