diff --git a/magnum/conductor/k8s_api.py b/magnum/conductor/k8s_api.py index d1419bedc2..97a4b98a99 100644 --- a/magnum/conductor/k8s_api.py +++ b/magnum/conductor/k8s_api.py @@ -46,20 +46,14 @@ class K8sAPI(ApivbetaApi.ApivbetaApi): @staticmethod def _retrieve_k8s_api_endpoint(context, obj): - apiserver_port = cfg.CONF.kubernetes.k8s_port if hasattr(obj, 'bay_uuid'): obj = utils.retrieve_bay(context, obj) - baymodel = utils.retrieve_baymodel(context, obj) - if baymodel.apiserver_port is not None: - apiserver_port = baymodel.apiserver_port - params = { 'k8s_protocol': cfg.CONF.kubernetes.k8s_protocol, - 'k8s_port': apiserver_port, 'api_address': obj.api_address } - return "%(k8s_protocol)s://%(api_address)s:%(k8s_port)s" % params + return "%(k8s_protocol)s://%(api_address)s" % params def create_k8s_api(context, obj): diff --git a/magnum/conductor/template_definition.py b/magnum/conductor/template_definition.py index f5eef09ea2..7d11e0a72e 100644 --- a/magnum/conductor/template_definition.py +++ b/magnum/conductor/template_definition.py @@ -353,7 +353,7 @@ class AtomicK8sTemplateDefinition(BaseTemplateDefinition): # self.add_parameter('apiserver_port', # baymodel_attr='apiserver_port') - self.add_output('kube_master', + self.add_output('api_address', bay_attr='api_address') self.add_output('kube_minions', bay_attr=None) diff --git a/magnum/templates/heat-kubernetes/kubecluster.yaml b/magnum/templates/heat-kubernetes/kubecluster.yaml index 59fde8c7eb..17d25e738a 100644 --- a/magnum/templates/heat-kubernetes/kubecluster.yaml +++ b/magnum/templates/heat-kubernetes/kubecluster.yaml @@ -401,14 +401,14 @@ outputs: params: api_ip_address: {get_attr: [api_pool_floating, floating_ip_address]} description: > - This is the IP address and port of the Kubernetes API server. + This is the API endpoint of the Kubernetes server. Use this to access + the Kubernetes API from outside the cluster. kube_master: value: {get_attr: [kube_master_floating, floating_ip_address]} description: > This is the "public" ip address of the Kubernetes master server. Use this address to - log in to the Kubernetes master via ssh or to access the Kubernetes API - from outside the cluster. + log in to the Kubernetes master via ssh. kube_minions: value: {get_attr: [kube_minions, kube_minion_ip]} diff --git a/magnum/tests/functional/test_magnum_python_client.py b/magnum/tests/functional/test_magnum_python_client.py index 97750ea50f..3e1ccd51d8 100644 --- a/magnum/tests/functional/test_magnum_python_client.py +++ b/magnum/tests/functional/test_magnum_python_client.py @@ -208,9 +208,9 @@ class TestKubernetesAPIs(BaseMagnumClient): super(TestKubernetesAPIs, cls).setUpClass() cls.baymodel = cls._create_baymodel('testk8sAPI') cls.bay = cls._create_bay('testk8sAPI', cls.baymodel.uuid) - kube_master_ip = cls.cs.bays.get(cls.bay.uuid).api_address - kube_master_url = 'http://%s:8080' % kube_master_ip - k8s_client = swagger.ApiClient(kube_master_url) + kube_api_address = cls.cs.bays.get(cls.bay.uuid).api_address + kube_api_url = 'http://%s' % kube_api_address + k8s_client = swagger.ApiClient(kube_api_url) cls.k8s_api = ApivbetaApi.ApivbetaApi(k8s_client) @classmethod diff --git a/magnum/tests/unit/conductor/handlers/test_bay_conductor.py b/magnum/tests/unit/conductor/handlers/test_bay_conductor.py index cec2030da1..c79afe26d4 100644 --- a/magnum/tests/unit/conductor/handlers/test_bay_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_bay_conductor.py @@ -284,7 +284,7 @@ class TestBayConductorWithK8s(base.TestCase): "output_key": "kube_minions_external"}, {"output_value": expected_api_address, "description": "No description given", - "output_key": "kube_master"}, + "output_key": "api_address"}, {"output_value": ['any', 'output'], "description": "No description given", "output_key": "kube_minions"} diff --git a/magnum/tests/unit/conductor/test_k8s_api.py b/magnum/tests/unit/conductor/test_k8s_api.py index 19cec07348..b0a3185ae6 100644 --- a/magnum/tests/unit/conductor/test_k8s_api.py +++ b/magnum/tests/unit/conductor/test_k8s_api.py @@ -22,55 +22,25 @@ from magnum.tests import base class TestK8sAPI(base.TestCase): - def _test_retrieve_k8s_api_endpoint(self, mock_baymodel_get_by_uuid, - mock_bay_get_by_uuid, - apiserver_port=None): + @patch('magnum.objects.Bay.get_by_uuid') + def test_retrieve_k8s_api_endpoint(self, mock_bay_get_by_uuid): expected_context = 'context' expected_api_address = 'api_address' - expected_baymodel_id = 'e74c40e0-d825-11e2-a28f-0800200c9a61' expected_protocol = cfg.CONF.kubernetes.k8s_protocol - if apiserver_port is None: - expected_apiserver_port = cfg.CONF.kubernetes.k8s_port - else: - expected_apiserver_port = apiserver_port resource = objects.Pod({}) resource.bay_uuid = 'bay_uuid' bay = objects.Bay({}) bay.api_address = expected_api_address - bay.baymodel_id = expected_baymodel_id - baymodel = objects.BayModel({}) - baymodel.apiserver_port = apiserver_port mock_bay_get_by_uuid.return_value = bay - mock_baymodel_get_by_uuid.return_value = baymodel actual_api_endpoint = k8s_api.K8sAPI._retrieve_k8s_api_endpoint( expected_context, resource) - self.assertEqual("%s://%s:%d" % (expected_protocol, - expected_api_address, - expected_apiserver_port), + self.assertEqual("%s://%s" % (expected_protocol, + expected_api_address), actual_api_endpoint) - @patch('magnum.objects.Bay.get_by_uuid') - @patch('magnum.objects.BayModel.get_by_uuid') - def test_retrieve_k8s_api_endpoint( - self, - mock_baymodel_get_by_uuid, - mock_bay_get_by_uuid): - self._test_retrieve_k8s_api_endpoint(mock_baymodel_get_by_uuid, - mock_bay_get_by_uuid, - apiserver_port=9999) - - @patch('magnum.objects.Bay.get_by_uuid') - @patch('magnum.objects.BayModel.get_by_uuid') - def test_retrieve_k8s_api_endpoint_without_baymodel_apiserver_port( - self, - mock_baymodel_get_by_uuid, - mock_bay_get_by_uuid): - self._test_retrieve_k8s_api_endpoint(mock_baymodel_get_by_uuid, - mock_bay_get_by_uuid) - @patch('magnum.conductor.k8s_api.K8sAPI') def test_create_k8s_api(self, mock_k8s_api_cls): context = 'context'