Skip to content

Commit c066a9f

Browse files
authored
Merge pull request #1617 from grycap/devel
Devel
2 parents a728315 + 2e8f14a commit c066a9f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

IM/connectors/Kubernetes.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class KubernetesCloudConnector(CloudConnector):
4848
"""Dictionary with a map with the Kubernetes POD states to the IM states."""
4949

5050
def create_request(self, method, url, auth_data, headers=None, body=None):
51-
auth_header, _ = self.get_auth_header(auth_data)
51+
auth_header, _, _ = self.get_auth_header(auth_data)
5252
if auth_header:
5353
if headers is None:
5454
headers = {}
@@ -91,7 +91,11 @@ def get_auth_header(self, auth_data):
9191
if 'namespace' in auth:
9292
namespace = auth['namespace']
9393

94-
return auth_header, namespace
94+
apps_dns = None
95+
if 'apps_dns' in auth:
96+
apps_dns = auth['apps_dns']
97+
98+
return auth_header, namespace, apps_dns
9599

96100
def concrete_system(self, radl_system, str_url, auth_data):
97101
url = urlparse(str_url)
@@ -331,7 +335,8 @@ def _generate_service_data(self, namespace, name, outports, public):
331335

332336
def create_ingress(self, namespace, name, dns, port, auth_data):
333337
try:
334-
ingress_data = self._generate_ingress_data(namespace, name, dns, port)
338+
_, _, apps_dns = self.get_auth_header(auth_data)
339+
ingress_data = self._generate_ingress_data(namespace, name, dns, port, apps_dns)
335340
self.log_debug("Creating Ingress: %s/%s" % (namespace, name))
336341
headers = {'Content-Type': 'application/json'}
337342
uri = "/apis/networking.k8s.io/v1/namespaces/%s/ingresses" % namespace
@@ -347,7 +352,7 @@ def create_ingress(self, namespace, name, dns, port, auth_data):
347352
self.log_exception("Error creating ingress.")
348353
return False
349354

350-
def _generate_ingress_data(self, namespace, name, dns, port):
355+
def _generate_ingress_data(self, namespace, name, dns, port, apps_dns):
351356
ingress_data = self._gen_basic_k8s_elem(namespace, name, 'Ingress', 'networking.k8s.io/v1')
352357

353358
host = None
@@ -364,6 +369,8 @@ def _generate_ingress_data(self, namespace, name, dns, port):
364369
secure = True
365370
if dns_url[1]:
366371
host = dns_url[1]
372+
if apps_dns and not host.endswith(apps_dns):
373+
host += "." + apps_dns
367374
if dns_url[2]:
368375
path = dns_url[2]
369376

@@ -503,7 +510,7 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm
503510
return pod_data
504511

505512
def _get_namespace(self, inf, auth_data):
506-
_, namespace = self.get_auth_header(auth_data)
513+
_, namespace, _ = self.get_auth_header(auth_data)
507514
# If the namespace is set in the auth_data use it
508515
if not namespace:
509516
# If not by default use the Inf ID as namespace

0 commit comments

Comments
 (0)