diff --git a/fuel_ccp/common/utils.py b/fuel_ccp/common/utils.py index f057731a..75f1f78a 100644 --- a/fuel_ccp/common/utils.py +++ b/fuel_ccp/common/utils.py @@ -65,7 +65,8 @@ def address(service, port=None, external=False, with_scheme=False): addr = '%s:%s' % (CONF.configs.k8s_external_ip, port['node']) if addr is None: - addr = '%s.%s' % (service, CONF.kubernetes.namespace) + addr = '.'.join((service, CONF.kubernetes.namespace, 'svc', + CONF.kubernetes.cluster_domain)) if port: addr = '%s:%s' % (addr, port['cont']) diff --git a/fuel_ccp/config/__init__.py b/fuel_ccp/config/__init__.py index 5dfff061..d3791c13 100644 --- a/fuel_ccp/config/__init__.py +++ b/fuel_ccp/config/__init__.py @@ -131,6 +131,8 @@ def load_component_defaults(): global _REAL_CONF new_config['configs']['namespace'] = _REAL_CONF.kubernetes.namespace + new_config['configs'][ + 'cluster_domain'] = _REAL_CONF.kubernetes.cluster_domain new_config._merge(_REAL_CONF) _REAL_CONF = new_config diff --git a/fuel_ccp/config/kubernetes.py b/fuel_ccp/config/kubernetes.py index 192e4ed2..d1e5f726 100644 --- a/fuel_ccp/config/kubernetes.py +++ b/fuel_ccp/config/kubernetes.py @@ -6,6 +6,7 @@ DEFAULTS = { 'key_file': None, 'cert_file': None, 'insecure': None, + 'cluster_domain': 'cluster.local', }, } @@ -20,6 +21,7 @@ SCHEMA = { 'key_file': {'anyOf': [{'type': 'string'}, {'type': 'null'}]}, 'cert_file': {'anyOf': [{'type': 'string'}, {'type': 'null'}]}, 'insecure': {'anyOf': [{'type': 'string'}, {'type': 'null'}]}, + 'cluster_domain': {'type': 'string'}, }, }, } diff --git a/fuel_ccp/tests/common/test_jinja_utils.py b/fuel_ccp/tests/common/test_jinja_utils.py index e1682d77..9bb83ef9 100644 --- a/fuel_ccp/tests/common/test_jinja_utils.py +++ b/fuel_ccp/tests/common/test_jinja_utils.py @@ -18,7 +18,8 @@ class TestJinjaUtils(base.TestCase): content = jinja_utils.jinja_render(self.filename, context, functions=[utils.address]) self.assertEqual( - "debian\njessie\nsome maintainer\nneedle\nneedle\nkeystone.ccp", + "debian\njessie\nsome maintainer\nneedle\nneedle\n" + "keystone.ccp.svc.cluster.local", content) context = { @@ -38,7 +39,8 @@ class TestJinjaUtils(base.TestCase): self.filename, context, functions=[utils.address], ignore_undefined=True) self.assertEqual( - "debian\njessie\nsome maintainer\nneedle\nneedle\nkeystone.ccp", + "debian\njessie\nsome maintainer\nneedle\nneedle\n" + "keystone.ccp.svc.cluster.local", content) context = { @@ -48,4 +50,4 @@ class TestJinjaUtils(base.TestCase): self.filename, context, functions=[utils.address], ignore_undefined=True) self.assertEqual( - "debian\n\n\n\n\nkeystone.ccp", content) + "debian\n\n\n\n\nkeystone.ccp.svc.cluster.local", content) diff --git a/fuel_ccp/tests/common/test_utils.py b/fuel_ccp/tests/common/test_utils.py index e02ce3d9..ffa04152 100644 --- a/fuel_ccp/tests/common/test_utils.py +++ b/fuel_ccp/tests/common/test_utils.py @@ -126,15 +126,17 @@ class TestUtils(base.TestCase): class TestAddress(testscenarios.WithScenarios, base.TestCase): scenarios = ( - ('internal_without_port', {'address': 'service.ccp'}), - ('internal_with_port', {'address': 'service.ccp:1234', - 'port': {'cont': 1234}}), + ('internal_without_port', + {'address': 'service.ccp.svc.cluster.local'}), + ('internal_with_port', + {'address': 'service.ccp.svc.cluster.local:1234', + 'port': {'cont': 1234}}), ('external_with_nodeport', {'address': '1.1.1.1:30000', 'external': True, 'ingress': False, 'port': {'cont': 1234, 'ingress': 'test', 'node': 30000}}), ('external_without_ingress_and_nodeport', - {'address': 'service.ccp:1234', 'external': True, 'ingress': False, - 'port': {'cont': 1234, 'ingress': 'test'}}), + {'address': 'service.ccp.svc.cluster.local:1234', 'external': True, + 'ingress': False, 'port': {'cont': 1234, 'ingress': 'test'}}), ('external_with_ingress_enabled', {'address': 'test.ccp.external:8443', 'external': True, 'ingress': True, 'port': {'cont': 1234, 'ingress': 'test'}}), @@ -142,10 +144,11 @@ class TestAddress(testscenarios.WithScenarios, base.TestCase): {'address': '1.1.1.1:30000', 'external': True, 'ingress': True, 'port': {'cont': 1234, 'node': 30000}}), ('external_with_ingress_and_nodeport_not_provided', - {'address': 'service.ccp:1234', 'external': True, 'ingress': True, - 'port': {'cont': 1234}}), - ('internal_with_scheme', {'address': 'http://service.ccp', - 'with_scheme': True}), + {'address': 'service.ccp.svc.cluster.local:1234', 'external': True, + 'ingress': True, 'port': {'cont': 1234}}), + ('internal_with_scheme', + {'address': 'http://service.ccp.svc.cluster.local', + 'with_scheme': True}), ('external_with_ingress_with_scheme', {'address': 'https://test.ccp.external:8443', 'external': True, 'ingress': True, 'port': {'cont': 1234, 'ingress': 'test'}, diff --git a/fuel_ccp/tests/test_deploy.py b/fuel_ccp/tests/test_deploy.py index c4d5dfed..b9872c21 100644 --- a/fuel_ccp/tests/test_deploy.py +++ b/fuel_ccp/tests/test_deploy.py @@ -117,7 +117,7 @@ class TestDeploy(base.TestCase): "export OS_USERNAME=%s" % config['openstack']['user_name'], "export OS_PASSWORD=%s" % config['openstack']['user_password'], "export OS_IDENTITY_API_VERSION=3", - "export OS_AUTH_URL=http://keystone.ccp:%s/v3" % + "export OS_AUTH_URL=http://keystone.ccp.svc.cluster.local:%s/v3" % config['keystone']['public_port']['cont'], ]