Merge pull request #62169 from Cynerva/gkk/apiserver-advertise-address

Automatic merge from submit-queue (batch tested with PRs 62063, 62169, 62155, 62139, 61445). 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>.

juju: Set apiserver advertise-address to kube-control ingress address

**What this PR does / why we need it**:

This fixes pod->apiserver traffic not obeying Juju network space bindings, by setting `--advertise-address` on kube-apiserver to the ingress address of the kube-control relation.

**Release note**:

```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-04-05 17:42:03 -07:00 committed by GitHub
commit e7ae2c62c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -559,9 +559,9 @@ def push_service_data(kube_api):
kube_api.configure(port=6443)
def get_ingress_address(relation):
def get_ingress_address(relation_name):
try:
network_info = hookenv.network_get(relation.relation_name)
network_info = hookenv.network_get(relation_name)
except NotImplementedError:
network_info = []
@ -585,7 +585,7 @@ def send_data(tls, kube_api_endpoint):
kubernetes_service_ip = get_kubernetes_service_ip()
# Get ingress address
ingress_ip = get_ingress_address(kube_api_endpoint)
ingress_ip = get_ingress_address(kube_api_endpoint.relation_name)
domain = hookenv.config('dns_domain')
# Create SANs that the tls layer will add to the server cert.
@ -1156,6 +1156,7 @@ def configure_apiserver(etcd_connection_string, leader_etcd_version):
api_opts['service-account-key-file'] = '/root/cdk/serviceaccount.key'
api_opts['kubelet-preferred-address-types'] = \
'[InternalIP,Hostname,InternalDNS,ExternalDNS,ExternalIP]'
api_opts['advertise-address'] = get_ingress_address('kube-control')
etcd_dir = '/root/cdk/etcd'
etcd_ca = os.path.join(etcd_dir, 'client-ca.pem')