@@ -48,7 +48,7 @@ class KubernetesCloudConnector(CloudConnector):
48
48
"""Dictionary with a map with the Kubernetes POD states to the IM states."""
49
49
50
50
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 )
52
52
if auth_header :
53
53
if headers is None :
54
54
headers = {}
@@ -91,7 +91,11 @@ def get_auth_header(self, auth_data):
91
91
if 'namespace' in auth :
92
92
namespace = auth ['namespace' ]
93
93
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
95
99
96
100
def concrete_system (self , radl_system , str_url , auth_data ):
97
101
url = urlparse (str_url )
@@ -331,7 +335,8 @@ def _generate_service_data(self, namespace, name, outports, public):
331
335
332
336
def create_ingress (self , namespace , name , dns , port , auth_data ):
333
337
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 )
335
340
self .log_debug ("Creating Ingress: %s/%s" % (namespace , name ))
336
341
headers = {'Content-Type' : 'application/json' }
337
342
uri = "/apis/networking.k8s.io/v1/namespaces/%s/ingresses" % namespace
@@ -347,7 +352,7 @@ def create_ingress(self, namespace, name, dns, port, auth_data):
347
352
self .log_exception ("Error creating ingress." )
348
353
return False
349
354
350
- def _generate_ingress_data (self , namespace , name , dns , port ):
355
+ def _generate_ingress_data (self , namespace , name , dns , port , apps_dns ):
351
356
ingress_data = self ._gen_basic_k8s_elem (namespace , name , 'Ingress' , 'networking.k8s.io/v1' )
352
357
353
358
host = None
@@ -364,6 +369,8 @@ def _generate_ingress_data(self, namespace, name, dns, port):
364
369
secure = True
365
370
if dns_url [1 ]:
366
371
host = dns_url [1 ]
372
+ if apps_dns and not host .endswith (apps_dns ):
373
+ host += "." + apps_dns
367
374
if dns_url [2 ]:
368
375
path = dns_url [2 ]
369
376
@@ -503,7 +510,7 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm
503
510
return pod_data
504
511
505
512
def _get_namespace (self , inf , auth_data ):
506
- _ , namespace = self .get_auth_header (auth_data )
513
+ _ , namespace , _ = self .get_auth_header (auth_data )
507
514
# If the namespace is set in the auth_data use it
508
515
if not namespace :
509
516
# If not by default use the Inf ID as namespace
0 commit comments