Browse Source

Merge "[k8s] Add new label `service_cluster_ip_range`"

tags/8.0.0.0rc1
Zuul 9 months ago
parent
commit
7b6415a5bc

+ 3
- 0
doc/source/user/index.rst View File

@@ -362,6 +362,9 @@ the table are linked to more details elsewhere in the user guide.
362 362
 | `cloud_provider_enabled`_             | - true             | true          |
363 363
 |                                       | - false            |               |
364 364
 +---------------------------------------+--------------------+---------------+
365
+| `service_cluster_ip_range`            | IPv4 CIDR for k8s  | 10.254.0.0/16 |
366
+|                                       | service portals    |               |
367
++---------------------------------------+--------------------+---------------+
365 368
 
366 369
 Cluster
367 370
 -------

+ 4
- 0
magnum/drivers/heat/k8s_template_def.py View File

@@ -130,6 +130,10 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
130 130
         for label in label_list:
131 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 137
         if cluster_template.registry_enabled:
134 138
             extra_params['swift_region'] = CONF.docker_registry.swift_region
135 139
             extra_params['registry_container'] = (

+ 11
- 2
magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py View File

@@ -59,7 +59,8 @@ class TestClusterConductorWithK8s(base.TestCase):
59 59
                        'influx_grafana_dashboard_enabled': 'True',
60 60
                        'docker_volume_type': 'lvmdriver-1',
61 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 64
             'tls_disabled': False,
64 65
             'server_type': 'vm',
65 66
             'registry_enabled': False,
@@ -107,7 +108,8 @@ class TestClusterConductorWithK8s(base.TestCase):
107 108
                        'kubecontroller_options': '--kubecontroller',
108 109
                        'kubescheduler_options': '--kubescheduler',
109 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 113
             'master_flavor_id': 'master_flavor_id',
112 114
             'flavor_id': 'flavor_id',
113 115
         }
@@ -217,6 +219,7 @@ class TestClusterConductorWithK8s(base.TestCase):
217 219
                        'kubecontroller_options': '--kubecontroller',
218 220
                        'kubescheduler_options': '--kubescheduler',
219 221
                        'kubeproxy_options': '--kubeproxy',
222
+                       'service_cluster_ip_range': '10.254.0.0/16',
220 223
                        },
221 224
             'http_proxy': 'http_proxy',
222 225
             'https_proxy': 'https_proxy',
@@ -286,6 +289,7 @@ class TestClusterConductorWithK8s(base.TestCase):
286 289
             'octavia_enabled': False,
287 290
             'kube_service_account_key': 'public_key',
288 291
             'kube_service_account_private_key': 'private_key',
292
+            'portal_network_cidr': '10.254.0.0/16',
289 293
         }
290 294
         if missing_attr is not None:
291 295
             expected.pop(mapping[missing_attr], None)
@@ -405,6 +409,7 @@ class TestClusterConductorWithK8s(base.TestCase):
405 409
             'octavia_enabled': False,
406 410
             'kube_service_account_key': 'public_key',
407 411
             'kube_service_account_private_key': 'private_key',
412
+            'portal_network_cidr': '10.254.0.0/16',
408 413
         }
409 414
 
410 415
         self.assertEqual(expected, definition)
@@ -511,6 +516,7 @@ class TestClusterConductorWithK8s(base.TestCase):
511 516
             'octavia_enabled': False,
512 517
             'kube_service_account_key': 'public_key',
513 518
             'kube_service_account_private_key': 'private_key',
519
+            'portal_network_cidr': '10.254.0.0/16',
514 520
         }
515 521
         self.assertEqual(expected, definition)
516 522
         self.assertEqual(
@@ -600,6 +606,7 @@ class TestClusterConductorWithK8s(base.TestCase):
600 606
             'kubescheduler_options': '--kubescheduler',
601 607
             'kubeproxy_options': '--kubeproxy',
602 608
             'octavia_enabled': False,
609
+            'portal_network_cidr': '10.254.0.0/16',
603 610
         }
604 611
         self.assertEqual(expected, definition)
605 612
         self.assertEqual(
@@ -684,6 +691,7 @@ class TestClusterConductorWithK8s(base.TestCase):
684 691
             'kubescheduler_options': '--kubescheduler',
685 692
             'kubeproxy_options': '--kubeproxy',
686 693
             'octavia_enabled': False,
694
+            'portal_network_cidr': '10.254.0.0/16',
687 695
         }
688 696
         self.assertEqual(expected, definition)
689 697
         self.assertEqual(
@@ -922,6 +930,7 @@ class TestClusterConductorWithK8s(base.TestCase):
922 930
             'octavia_enabled': False,
923 931
             'kube_service_account_key': 'public_key',
924 932
             'kube_service_account_private_key': 'private_key',
933
+            'portal_network_cidr': '10.254.0.0/16',
925 934
         }
926 935
         self.assertEqual(expected, definition)
927 936
         self.assertEqual(

+ 6
- 0
magnum/tests/unit/drivers/test_template_definition.py View File

@@ -371,6 +371,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
371 371
             'kubeproxy_options')
372 372
         cloud_provider_enabled = mock_cluster.labels.get(
373 373
             'cloud_provider_enabled')
374
+        service_cluster_ip_range = mock_cluster.labels.get(
375
+            'service_cluster_ip_range')
374 376
 
375 377
         k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition()
376 378
 
@@ -420,6 +422,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
420 422
             'octavia_enabled': False,
421 423
             'kube_service_account_key': 'public_key',
422 424
             'kube_service_account_private_key': 'private_key',
425
+            'portal_network_cidr': service_cluster_ip_range,
423 426
         }}
424 427
         mock_get_params.assert_called_once_with(mock_context,
425 428
                                                 mock_cluster_template,
@@ -541,6 +544,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
541 544
             'kubeproxy_options')
542 545
         cloud_provider_enabled = mock_cluster.labels.get(
543 546
             'cloud_provider_enabled')
547
+        service_cluster_ip_range = mock_cluster.labels.get(
548
+            'service_cluster_ip_range')
544 549
 
545 550
         k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition()
546 551
 
@@ -592,6 +597,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
592 597
             'octavia_enabled': False,
593 598
             'kube_service_account_key': 'public_key',
594 599
             'kube_service_account_private_key': 'private_key',
600
+            'portal_network_cidr': service_cluster_ip_range,
595 601
         }}
596 602
         mock_get_params.assert_called_once_with(mock_context,
597 603
                                                 mock_cluster_template,

+ 6
- 0
releasenotes/notes/add-k8s-label-for-portal-network-cidr-a09edab29da6e7da.yaml View File

@@ -0,0 +1,6 @@
1
+---
2
+fixes:
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
+

Loading…
Cancel
Save