summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-08-29 07:57:50 +0000
committerGerrit Code Review <review@openstack.org>2018-08-29 07:57:50 +0000
commit7b6415a5bc5a3c5b9dd40ab15a5f02461d42d35b (patch)
tree43b532555864ee48234582f45fea54e8142dc99b
parent85981d893da151702652dbcad903cbca06cacdc4 (diff)
parent80fcf76d27f961685150cf0a43931446dc817b16 (diff)
Merge "[k8s] Add new label `service_cluster_ip_range`"
-rw-r--r--doc/source/user/index.rst3
-rw-r--r--magnum/drivers/heat/k8s_template_def.py4
-rw-r--r--magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py13
-rw-r--r--magnum/tests/unit/drivers/test_template_definition.py6
-rw-r--r--releasenotes/notes/add-k8s-label-for-portal-network-cidr-a09edab29da6e7da.yaml6
5 files changed, 30 insertions, 2 deletions
diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst
index 07aaa62..5ae5b45 100644
--- a/doc/source/user/index.rst
+++ b/doc/source/user/index.rst
@@ -362,6 +362,9 @@ the table are linked to more details elsewhere in the user guide.
362| `cloud_provider_enabled`_ | - true | true | 362| `cloud_provider_enabled`_ | - true | true |
363| | - false | | 363| | - false | |
364+---------------------------------------+--------------------+---------------+ 364+---------------------------------------+--------------------+---------------+
365| `service_cluster_ip_range` | IPv4 CIDR for k8s | 10.254.0.0/16 |
366| | service portals | |
367+---------------------------------------+--------------------+---------------+
365 368
366Cluster 369Cluster
367------- 370-------
diff --git a/magnum/drivers/heat/k8s_template_def.py b/magnum/drivers/heat/k8s_template_def.py
index c7e12be..d0e0592 100644
--- a/magnum/drivers/heat/k8s_template_def.py
+++ b/magnum/drivers/heat/k8s_template_def.py
@@ -130,6 +130,10 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
130 for label in label_list: 130 for label in label_list:
131 extra_params[label] = cluster.labels.get(label) 131 extra_params[label] = cluster.labels.get(label)
132 132
133 cluser_ip_range = cluster.labels.get('service_cluster_ip_range')
134 if cluser_ip_range:
135 extra_params['portal_network_cidr'] = cluser_ip_range
136
133 if cluster_template.registry_enabled: 137 if cluster_template.registry_enabled:
134 extra_params['swift_region'] = CONF.docker_registry.swift_region 138 extra_params['swift_region'] = CONF.docker_registry.swift_region
135 extra_params['registry_container'] = ( 139 extra_params['registry_container'] = (
diff --git a/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py b/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
index 099e33b..542af69 100644
--- a/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
+++ b/magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
@@ -59,7 +59,8 @@ class TestClusterConductorWithK8s(base.TestCase):
59 'influx_grafana_dashboard_enabled': 'True', 59 'influx_grafana_dashboard_enabled': 'True',
60 'docker_volume_type': 'lvmdriver-1', 60 'docker_volume_type': 'lvmdriver-1',
61 'etcd_volume_size': 0, 61 'etcd_volume_size': 0,
62 'availability_zone': 'az_1'}, 62 'availability_zone': 'az_1',
63 'service_cluster_ip_range': '10.254.0.0/16'},
63 'tls_disabled': False, 64 'tls_disabled': False,
64 'server_type': 'vm', 65 'server_type': 'vm',
65 'registry_enabled': False, 66 'registry_enabled': False,
@@ -107,7 +108,8 @@ class TestClusterConductorWithK8s(base.TestCase):
107 'kubecontroller_options': '--kubecontroller', 108 'kubecontroller_options': '--kubecontroller',
108 'kubescheduler_options': '--kubescheduler', 109 'kubescheduler_options': '--kubescheduler',
109 'kubeproxy_options': '--kubeproxy', 110 'kubeproxy_options': '--kubeproxy',
110 'influx_grafana_dashboard_enabled': 'True'}, 111 'influx_grafana_dashboard_enabled': 'True',
112 'service_cluster_ip_range': '10.254.0.0/16'},
111 'master_flavor_id': 'master_flavor_id', 113 'master_flavor_id': 'master_flavor_id',
112 'flavor_id': 'flavor_id', 114 'flavor_id': 'flavor_id',
113 } 115 }
@@ -217,6 +219,7 @@ class TestClusterConductorWithK8s(base.TestCase):
217 'kubecontroller_options': '--kubecontroller', 219 'kubecontroller_options': '--kubecontroller',
218 'kubescheduler_options': '--kubescheduler', 220 'kubescheduler_options': '--kubescheduler',
219 'kubeproxy_options': '--kubeproxy', 221 'kubeproxy_options': '--kubeproxy',
222 'service_cluster_ip_range': '10.254.0.0/16',
220 }, 223 },
221 'http_proxy': 'http_proxy', 224 'http_proxy': 'http_proxy',
222 'https_proxy': 'https_proxy', 225 'https_proxy': 'https_proxy',
@@ -286,6 +289,7 @@ class TestClusterConductorWithK8s(base.TestCase):
286 'octavia_enabled': False, 289 'octavia_enabled': False,
287 'kube_service_account_key': 'public_key', 290 'kube_service_account_key': 'public_key',
288 'kube_service_account_private_key': 'private_key', 291 'kube_service_account_private_key': 'private_key',
292 'portal_network_cidr': '10.254.0.0/16',
289 } 293 }
290 if missing_attr is not None: 294 if missing_attr is not None:
291 expected.pop(mapping[missing_attr], None) 295 expected.pop(mapping[missing_attr], None)
@@ -405,6 +409,7 @@ class TestClusterConductorWithK8s(base.TestCase):
405 'octavia_enabled': False, 409 'octavia_enabled': False,
406 'kube_service_account_key': 'public_key', 410 'kube_service_account_key': 'public_key',
407 'kube_service_account_private_key': 'private_key', 411 'kube_service_account_private_key': 'private_key',
412 'portal_network_cidr': '10.254.0.0/16',
408 } 413 }
409 414
410 self.assertEqual(expected, definition) 415 self.assertEqual(expected, definition)
@@ -511,6 +516,7 @@ class TestClusterConductorWithK8s(base.TestCase):
511 'octavia_enabled': False, 516 'octavia_enabled': False,
512 'kube_service_account_key': 'public_key', 517 'kube_service_account_key': 'public_key',
513 'kube_service_account_private_key': 'private_key', 518 'kube_service_account_private_key': 'private_key',
519 'portal_network_cidr': '10.254.0.0/16',
514 } 520 }
515 self.assertEqual(expected, definition) 521 self.assertEqual(expected, definition)
516 self.assertEqual( 522 self.assertEqual(
@@ -600,6 +606,7 @@ class TestClusterConductorWithK8s(base.TestCase):
600 'kubescheduler_options': '--kubescheduler', 606 'kubescheduler_options': '--kubescheduler',
601 'kubeproxy_options': '--kubeproxy', 607 'kubeproxy_options': '--kubeproxy',
602 'octavia_enabled': False, 608 'octavia_enabled': False,
609 'portal_network_cidr': '10.254.0.0/16',
603 } 610 }
604 self.assertEqual(expected, definition) 611 self.assertEqual(expected, definition)
605 self.assertEqual( 612 self.assertEqual(
@@ -684,6 +691,7 @@ class TestClusterConductorWithK8s(base.TestCase):
684 'kubescheduler_options': '--kubescheduler', 691 'kubescheduler_options': '--kubescheduler',
685 'kubeproxy_options': '--kubeproxy', 692 'kubeproxy_options': '--kubeproxy',
686 'octavia_enabled': False, 693 'octavia_enabled': False,
694 'portal_network_cidr': '10.254.0.0/16',
687 } 695 }
688 self.assertEqual(expected, definition) 696 self.assertEqual(expected, definition)
689 self.assertEqual( 697 self.assertEqual(
@@ -922,6 +930,7 @@ class TestClusterConductorWithK8s(base.TestCase):
922 'octavia_enabled': False, 930 'octavia_enabled': False,
923 'kube_service_account_key': 'public_key', 931 'kube_service_account_key': 'public_key',
924 'kube_service_account_private_key': 'private_key', 932 'kube_service_account_private_key': 'private_key',
933 'portal_network_cidr': '10.254.0.0/16',
925 } 934 }
926 self.assertEqual(expected, definition) 935 self.assertEqual(expected, definition)
927 self.assertEqual( 936 self.assertEqual(
diff --git a/magnum/tests/unit/drivers/test_template_definition.py b/magnum/tests/unit/drivers/test_template_definition.py
index 04e509e..1024a13 100644
--- a/magnum/tests/unit/drivers/test_template_definition.py
+++ b/magnum/tests/unit/drivers/test_template_definition.py
@@ -371,6 +371,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
371 'kubeproxy_options') 371 'kubeproxy_options')
372 cloud_provider_enabled = mock_cluster.labels.get( 372 cloud_provider_enabled = mock_cluster.labels.get(
373 'cloud_provider_enabled') 373 'cloud_provider_enabled')
374 service_cluster_ip_range = mock_cluster.labels.get(
375 'service_cluster_ip_range')
374 376
375 k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition() 377 k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition()
376 378
@@ -420,6 +422,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
420 'octavia_enabled': False, 422 'octavia_enabled': False,
421 'kube_service_account_key': 'public_key', 423 'kube_service_account_key': 'public_key',
422 'kube_service_account_private_key': 'private_key', 424 'kube_service_account_private_key': 'private_key',
425 'portal_network_cidr': service_cluster_ip_range,
423 }} 426 }}
424 mock_get_params.assert_called_once_with(mock_context, 427 mock_get_params.assert_called_once_with(mock_context,
425 mock_cluster_template, 428 mock_cluster_template,
@@ -541,6 +544,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
541 'kubeproxy_options') 544 'kubeproxy_options')
542 cloud_provider_enabled = mock_cluster.labels.get( 545 cloud_provider_enabled = mock_cluster.labels.get(
543 'cloud_provider_enabled') 546 'cloud_provider_enabled')
547 service_cluster_ip_range = mock_cluster.labels.get(
548 'service_cluster_ip_range')
544 549
545 k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition() 550 k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition()
546 551
@@ -592,6 +597,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
592 'octavia_enabled': False, 597 'octavia_enabled': False,
593 'kube_service_account_key': 'public_key', 598 'kube_service_account_key': 'public_key',
594 'kube_service_account_private_key': 'private_key', 599 'kube_service_account_private_key': 'private_key',
600 'portal_network_cidr': service_cluster_ip_range,
595 }} 601 }}
596 mock_get_params.assert_called_once_with(mock_context, 602 mock_get_params.assert_called_once_with(mock_context,
597 mock_cluster_template, 603 mock_cluster_template,
diff --git a/releasenotes/notes/add-k8s-label-for-portal-network-cidr-a09edab29da6e7da.yaml b/releasenotes/notes/add-k8s-label-for-portal-network-cidr-a09edab29da6e7da.yaml
new file mode 100644
index 0000000..66fb51b
--- /dev/null
+++ b/releasenotes/notes/add-k8s-label-for-portal-network-cidr-a09edab29da6e7da.yaml
@@ -0,0 +1,6 @@
1---
2fixes:
3 - |
4 Add a new label `service_cluster_ip_range` for kubernetes so that user can
5 set the IP range for service portals to avoid conflicts with pod IP range.
6