Skip to content

Commit d940659

Browse files
mnasiadkaAlex-Welsh
authored andcommitted
Support extra_network and extra_subnet labels
This allows users to add extra network interface to cluster nodes, e.g. storage network. Story: 2002448 Task: 21983 Co-Authored-By: Bharat Kunwar <[email protected]> Change-Id: I10a6a4d72e9ec635f2c73d9fe64a8d136228f532 (cherry picked from commit bea8c72) (cherry picked from commit 8260f11) (cherry picked from commit d6c0a2d) (cherry picked from commit 6227555) (cherry picked from commit 3667d28) (cherry picked from commit 8562dde)
1 parent 57b2462 commit d940659

File tree

7 files changed

+195
-7
lines changed

7 files changed

+195
-7
lines changed

doc/source/user/index.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ the table are linked to more details elsewhere in the user guide.
467467
+---------------------------------------+--------------------+---------------+
468468
| `octavia_lb_healthcheck`_ | see bellow | true |
469469
+---------------------------------------+--------------------+---------------+
470+
| `extra_network`_ | see below | "" |
471+
+---------------------------------------+--------------------+---------------+
472+
| `extra_subnet`_ | see below | "" |
473+
+---------------------------------------+--------------------+---------------+
474+
| `extra_security_group`_ | see below | see below |
475+
+---------------------------------------+--------------------+---------------+
470476

471477
.. _cluster:
472478

@@ -1553,6 +1559,22 @@ _`octavia_lb_healthcheck`
15531559
If true, enable Octavia load balancer healthcheck
15541560
Default: true
15551561

1562+
_`extra_network`
1563+
Optional additional network name or UUID to add to cluster nodes.
1564+
When not specified, additional networks are not added. Optionally specify
1565+
'extra_subnet' if you wish to use a specific subnet on the network.
1566+
Default: ""
1567+
1568+
_`extra_subnet`
1569+
Optional additional subnet name or UUID to add to cluster nodes.
1570+
Only used when 'extra_network' is defined.
1571+
Default: ""
1572+
1573+
_`extra_security_group`
1574+
Optional additional group name or UUID to add to network port.
1575+
Only used when 'extra_network' is defined.
1576+
Default: cluster node default security group.
1577+
15561578
Supported versions
15571579
------------------
15581580

@@ -2319,7 +2341,6 @@ _`calico_tag`
23192341
Victoria default: v3.13.1
23202342
Wallaby default: v3.13.1
23212343

2322-
23232344
Besides, the Calico network driver needs kube_tag with v1.9.3 or later, because
23242345
Calico needs extra mounts for the kubelet container. See `commit
23252346
<https://github.com/projectatomic/atomic-system-containers/commit/54ab8abc7fa1bfb6fa674f55cd0c2fa0c812fd36>`_

magnum/drivers/heat/k8s_fedora_template_def.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def get_params(self, context, cluster_template, cluster, **kwargs):
123123
'min_node_count', 'max_node_count', 'npd_enabled',
124124
'ostree_remote', 'ostree_commit',
125125
'use_podman', 'kube_image_digest',
126-
'metrics_scraper_tag']
126+
'metrics_scraper_tag',
127+
'extra_network', 'extra_subnet', 'extra_security_group']
127128

128129
labels = self._get_relevant_labels(cluster, kwargs)
129130

magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,13 +989,32 @@ parameters:
989989
description: >
990990
Post install manifest URL used to setup some cloud provider/vendor
991991
specific configs
992-
default: ""
992+
default: ''
993993

994994
master_lb_allowed_cidrs:
995995
type: comma_delimited_list
996996
description: The allowed CIDR list for master load balancer
997997
default: []
998998

999+
extra_network:
1000+
type: string
1001+
description: >
1002+
Additional network to bind nodes to
1003+
default: ''
1004+
1005+
extra_subnet:
1006+
type: string
1007+
description: >
1008+
Subnet for additional network
1009+
default: ''
1010+
1011+
extra_security_group:
1012+
type: string
1013+
description: >
1014+
Additional security group name
1015+
default: ''
1016+
1017+
9991018
resources:
10001019

10011020
######################################################################
@@ -1384,6 +1403,9 @@ resources:
13841403
containerd_tarball_sha256: {get_param: containerd_tarball_sha256}
13851404
post_install_manifest_url: {get_param: post_install_manifest_url}
13861405
metrics_scraper_tag: {get_param: metrics_scraper_tag}
1406+
extra_network: {get_param: extra_network}
1407+
extra_subnet: {get_param: extra_subnet}
1408+
extra_security_group: {get_param: extra_security_group}
13871409

13881410
kube_cluster_config:
13891411
condition: create_cluster_resources
@@ -1566,6 +1588,10 @@ resources:
15661588
containerd_tarball_sha256: {get_param: containerd_tarball_sha256}
15671589
kube_service_account_key: {get_param: kube_service_account_key}
15681590
kube_service_account_private_key: {get_param: kube_service_account_private_key}
1591+
extra_network: {get_param: extra_network}
1592+
extra_subnet: {get_param: extra_subnet}
1593+
extra_security_group: {get_param: extra_security_group}
1594+
15691595
outputs:
15701596

15711597
api_address:

magnum/drivers/k8s_fedora_coreos_v1/templates/kubemaster.yaml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,21 @@ parameters:
698698
description: >
699699
Tag of metrics-scraper for kubernetes dashboard.
700700
701+
extra_network:
702+
type: string
703+
description: >
704+
Additional network name to bind ports to instances
705+
706+
extra_subnet:
707+
type: string
708+
description: >
709+
Additional subnet name
710+
711+
extra_security_group:
712+
type: string
713+
description: >
714+
Additional security group name
715+
701716
conditions:
702717

703718
image_based: {equals: [{get_param: boot_volume_size}, 0]}
@@ -707,6 +722,24 @@ conditions:
707722
- get_param: boot_volume_size
708723
- 0
709724

725+
extra_network_defined:
726+
not:
727+
equals:
728+
- get_param: extra_network
729+
- ''
730+
731+
extra_subnet_defined:
732+
not:
733+
equals:
734+
- get_param: extra_subnet
735+
- ''
736+
737+
extra_security_group_defined:
738+
not:
739+
equals:
740+
- get_param: extra_security_group
741+
- ''
742+
710743
resources:
711744
######################################################################
712745
#
@@ -965,7 +998,12 @@ resources:
965998
software_config_transport: POLL_SERVER_HEAT
966999
user_data: {get_resource: agent_config}
9671000
networks:
968-
- port: {get_resource: kube_master_eth0}
1001+
list_concat:
1002+
- - port: {get_resource: kube_master_eth0}
1003+
- if:
1004+
- "extra_network_defined"
1005+
- - port: {get_resource: kube_master_eth1}
1006+
- []
9691007
scheduler_hints: { group: { get_param: nodes_server_group_id }}
9701008
availability_zone: {get_param: availability_zone}
9711009

@@ -979,7 +1017,12 @@ resources:
9791017
software_config_transport: POLL_SERVER_HEAT
9801018
user_data: {get_resource: agent_config}
9811019
networks:
982-
- port: {get_resource: kube_master_eth0}
1020+
list_concat:
1021+
- - port: {get_resource: kube_master_eth0}
1022+
- if:
1023+
- "extra_network_defined"
1024+
- - port: {get_resource: kube_master_eth1}
1025+
- []
9831026
scheduler_hints: { group: { get_param: nodes_server_group_id }}
9841027
availability_zone: {get_param: availability_zone}
9851028
block_device_mapping_v2:
@@ -998,6 +1041,23 @@ resources:
9981041
- ip_address: {get_param: pods_network_cidr}
9991042
replacement_policy: AUTO
10001043

1044+
kube_master_eth1:
1045+
type: OS::Neutron::Port
1046+
condition: extra_network_defined
1047+
properties:
1048+
network: {get_param: extra_network}
1049+
security_groups:
1050+
- if:
1051+
- "extra_security_group_defined"
1052+
- {get_param: extra_security_group}
1053+
- {get_param: secgroup_kube_master_id}
1054+
fixed_ips:
1055+
if:
1056+
- "extra_subnet_defined"
1057+
- - subnet: {get_param: extra_subnet}
1058+
- []
1059+
replacement_policy: AUTO
1060+
10011061
kube_master_floating:
10021062
type: Magnum::Optional::KubeMaster::Neutron::FloatingIP
10031063
properties:

magnum/drivers/k8s_fedora_coreos_v1/templates/kubeminion.yaml

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,21 @@ parameters:
387387
The private key will be used to sign generated k8s service account
388388
tokens.
389389
390+
extra_network:
391+
type: string
392+
description: >
393+
Additional network name to bind ports to instances
394+
395+
extra_subnet:
396+
type: string
397+
description: >
398+
Additional subnet name
399+
400+
extra_security_group:
401+
type: string
402+
description: >
403+
Additional seurity group name
404+
390405
conditions:
391406

392407
image_based: {equals: [{get_param: boot_volume_size}, 0]}
@@ -396,6 +411,25 @@ conditions:
396411
- get_param: boot_volume_size
397412
- 0
398413

414+
extra_network_defined:
415+
not:
416+
equals:
417+
- get_param: extra_network
418+
- ''
419+
420+
extra_subnet_defined:
421+
not:
422+
equals:
423+
- get_param: extra_subnet
424+
- ''
425+
426+
extra_security_group_defined:
427+
not:
428+
equals:
429+
- get_param: extra_security_group
430+
- ''
431+
432+
399433
resources:
400434

401435
agent_config:
@@ -563,7 +597,12 @@ resources:
563597
user_data_format: SOFTWARE_CONFIG
564598
software_config_transport: POLL_SERVER_HEAT
565599
networks:
566-
- port: {get_resource: kube_minion_eth0}
600+
list_concat:
601+
- - port: {get_resource: kube_minion_eth0}
602+
- if:
603+
- "extra_network_defined"
604+
- - port: {get_resource: kube_minion_eth1}
605+
- []
567606
scheduler_hints: { group: { get_param: nodes_server_group_id }}
568607
availability_zone: {get_param: availability_zone}
569608

@@ -577,7 +616,12 @@ resources:
577616
user_data_format: SOFTWARE_CONFIG
578617
software_config_transport: POLL_SERVER_HEAT
579618
networks:
580-
- port: {get_resource: kube_minion_eth0}
619+
list_concat:
620+
- - port: {get_resource: kube_minion_eth0}
621+
- if:
622+
- "extra_network_defined"
623+
- - port: {get_resource: kube_minion_eth1}
624+
- []
581625
scheduler_hints: { group: { get_param: nodes_server_group_id }}
582626
availability_zone: {get_param: availability_zone}
583627
block_device_mapping_v2:
@@ -596,6 +640,23 @@ resources:
596640
- ip_address: {get_param: pods_network_cidr}
597641
replacement_policy: AUTO
598642

643+
kube_minion_eth1:
644+
type: OS::Neutron::Port
645+
condition: extra_network_defined
646+
properties:
647+
network: {get_param: extra_network}
648+
security_groups:
649+
- if:
650+
- "extra_security_group_defined"
651+
- get_param: extra_security_group
652+
- get_param: secgroup_kube_minion_id
653+
fixed_ips:
654+
if:
655+
- "extra_subnet_defined"
656+
- - subnet: {get_param: extra_subnet}
657+
- []
658+
replacement_policy: AUTO
659+
599660
kube_minion_floating:
600661
type: Magnum::Optional::KubeMinion::Neutron::FloatingIP
601662
properties:

magnum/tests/unit/drivers/test_template_definition.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ def test_k8s_get_params(self, mock_generate_csr_and_key,
553553
octavia_lb_algorithm = mock_cluster.labels.get('octavia_lb_algorithm')
554554
octavia_lb_healthcheck = mock_cluster.labels.get(
555555
'octavia_lb_healthcheck')
556+
extra_network = mock_cluster.labels.get('extra_network')
557+
extra_subnet = mock_cluster.labels.get('extra_subnet')
558+
extra_security_group = mock_cluster.labels.get('extra_security_group')
556559

557560
k8s_def = k8s_fcos_tdef.FCOSK8sTemplateDefinition()
558561

@@ -676,6 +679,9 @@ def test_k8s_get_params(self, mock_generate_csr_and_key,
676679
'octavia_provider': octavia_provider,
677680
'octavia_lb_algorithm': octavia_lb_algorithm,
678681
'octavia_lb_healthcheck': octavia_lb_healthcheck,
682+
'extra_network': extra_network,
683+
'extra_subnet': extra_subnet,
684+
'extra_security_group': extra_security_group,
679685
}}
680686
mock_get_params.assert_called_once_with(mock_context,
681687
mock_cluster_template,
@@ -1101,6 +1107,10 @@ def test_k8s_get_params_insecure(self, mock_generate_csr_and_key,
11011107

11021108
master_lb_allowed_cidrs = mock_cluster.labels.get(
11031109
'master_lb_allowed_cidrs')
1110+
extra_network = mock_cluster.labels.get('extra_network')
1111+
extra_subnet = mock_cluster.labels.get('extra_subnet')
1112+
extra_security_group = mock_cluster.labels.get('extra_security_group')
1113+
11041114

11051115
octavia_provider = mock_cluster.labels.get('octavia_provider')
11061116
octavia_lb_algorithm = mock_cluster.labels.get('octavia_lb_algorithm')
@@ -1231,6 +1241,9 @@ def test_k8s_get_params_insecure(self, mock_generate_csr_and_key,
12311241
'octavia_provider': octavia_provider,
12321242
'octavia_lb_algorithm': octavia_lb_algorithm,
12331243
'octavia_lb_healthcheck': octavia_lb_healthcheck,
1244+
'extra_network': extra_network,
1245+
'extra_subnet': extra_subnet,
1246+
'extra_security_group': extra_security_group,
12341247
}}
12351248
mock_get_params.assert_called_once_with(mock_context,
12361249
mock_cluster_template,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
Support extra_network and extra_subnet labels to allow users to assign
5+
extra network interface to cluster nodes, e.g. storage network. Also adds
6+
possibility to set custom security group on network port.

0 commit comments

Comments
 (0)