Skip to content

Commit

Permalink
Merge pull request juju#9608 from ycliuhw/fix/allow-ingress-controlle…
Browse files Browse the repository at this point in the history
…r-publish-address

juju#9608

## Description of change

fix `ingress` issues on `microk8s/kubernetes core` by patching ingress controller container exec args to allow ingress publish address;

before 
```
root@juju-bf04a4-1:~# kubectl -n testcaas get ing -o wide
NAME HOSTS ADDRESS PORTS AGE
juju-gitlab-k8s 10.98.42.46.xip.io 80 4m25s

```
after 
```
root@juju-bf04a4-1:~# kubectl -n testcaas get ing -o wide
NAME HOSTS ADDRESS PORTS AGE
juju-gitlab-k8s 10.98.42.46.xip.io 10.98.42.46 80 4m25s
```

## QA steps

N/A

## Documentation changes

N/A

## Bug reference

N/A
  • Loading branch information
jujubot authored Jan 10, 2019
2 parents 80f9a82 + a7fa48f commit 91fa969
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 11 additions & 3 deletions acceptancetests/assess_caas_deploy_charms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
import os
import subprocess
from time import sleep

import requests

Expand Down Expand Up @@ -162,11 +163,12 @@ def check_app_healthy(url, timeout=300):
for _ in until_timeout(timeout):
try:
r = requests.get(url)
if r.ok and r.status_code < 300:
if r.ok and r.status_code < 400:
return
status_code = r.status_code
except IOError as e:
log.error(e)
sleep(3)
log.error('HTTP health check failed -> %s, status_code -> %s !', url, status_code)
raise JujuAssertionError('gitlab is not healthy')

Expand All @@ -185,6 +187,14 @@ def assess_caas_charm_deployment(client):
if not caas_client.is_cluster_healthy:
raise JujuAssertionError('k8s cluster is not healthy because kubectl is not accessible')

# tmp fix kubernetes core ingress issue
caas_client.kubectl(
'patch', 'daemonset.apps/nginx-ingress-kubernetes-worker-controller', '--patch',
'''
{"spec": {"template": {"spec": {"containers": [{"name": "nginx-ingress-kubernetes-worker","args": ["/nginx-ingress-controller", "--default-backend-service=$(POD_NAMESPACE)/default-http-backend", "--configmap=$(POD_NAMESPACE)/nginx-load-balancer-conf", "---enable-ssl-chain-completion=False", "--publish-status-address=%s"]}]}}}}
''' % caas_client.get_first_worker_ip()
)

# add caas model for deploying caas charms on top of it
model_name = 'testcaas'
k8s_model = caas_client.add_model(model_name)
Expand Down Expand Up @@ -214,12 +224,10 @@ def assess_caas_charm_deployment(client):
k8s_model.deploy(
charm="cs:~juju/gitlab-k8s-0",
config='juju-external-hostname={}'.format(external_hostname),
resource="gitlab_image=gitlab/gitlab-ee:11.5.4-ee.0",
)

k8s_model.deploy(
charm="cs:~juju/mariadb-k8s-0",
resource="mysql_image=mysql/mysql-server:5.7",
storage='database=10M,{pool_name}'.format(pool_name=mariadb_storage_pool_name),
)

Expand Down
8 changes: 5 additions & 3 deletions acceptancetests/jujupy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,11 +2182,13 @@ def kubectl_apply(self, stdin):
log.debug(o)

def get_external_hostname(self):
status = self.client.get_status()
# assume here always use single node cdk core or microk8s
return '{}.xip.io'.format(self.get_first_worker_ip())

def get_first_worker_ip(self):
status = self.client.get_status()
unit = status.get_unit('kubernetes-worker/{}'.format(0))
ip = status.get_machine_dns_name(unit['machine'])
return '{}.xip.io'.format(ip)
return status.get_machine_dns_name(unit['machine'])


def register_user_interactively(client, token, controller_name):
Expand Down

0 comments on commit 91fa969

Please sign in to comment.