Skip to content

Commit 69b2031

Browse files
committed
Add nmstate templates and a baremetal nmstate scenario
Add the nmstate-format single_nic_vlans sample and a nmstate_baremetal scenario, and align the existing nmstate scenario with it: nic aliases, state: up on the ovs-bridge, MTU on the physical NIC, and loop over the route lists instead of reading attributes off a list, which rendered an empty destination and next-hop-address. Drop the hardcoded second node from the nmstate component so that it can be used in ci. Signed-off-by: Rabi Mishra <ramishra@redhat.com>
1 parent ea0a6b8 commit 69b2031

5 files changed

Lines changed: 212 additions & 24 deletions

File tree

‎config/samples/dataplane/nmstate/kustomization.yaml‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,3 @@ replacements:
2222
- spec.nodeTemplate.ansible.ansibleVars
2323
options:
2424
create: true
25-
26-
patches:
27-
- target:
28-
kind: OpenStackDataPlaneNodeSet
29-
name: .*
30-
patch: |-
31-
- op: copy
32-
from: /spec/nodes/edpm-compute-0
33-
path: /spec/nodes/edpm-compute-1
34-
- op: replace
35-
path: /spec/nodes/edpm-compute-1/ansible/ansibleHost
36-
value: 192.168.122.101
37-
- op: replace
38-
path: /spec/nodes/edpm-compute-1/hostName
39-
value: edpm-compute-1
40-
- op: replace
41-
path: /spec/nodes/edpm-compute-1/networks/0/fixedIP
42-
value: 192.168.122.101

‎config/samples/dataplane/nmstate/values.yaml‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ data:
2323
search: {{ dns_search_domains }}
2424
server: {{ ctlplane_dns_nameservers }}
2525
interfaces:
26-
- name: {{ neutron_public_interface_name }}
26+
- name: nic1
2727
type: ethernet
2828
state: up
29+
mtu: {{ min_viable_mtu }}
2930
- name: {{ neutron_physical_bridge_name }}
3031
type: ovs-interface
3132
state: up
@@ -48,29 +49,42 @@ data:
4849
{% endfor %}
4950
- name: {{ neutron_physical_bridge_name }}
5051
type: ovs-bridge
52+
state: up
5153
bridge:
5254
options:
5355
fail-mode: standalone
5456
port:
55-
- name: {{ neutron_public_interface_name }}
57+
- name: nic1
5658
- name: {{ neutron_physical_bridge_name }}
5759
{% for network in nodeset_networks %}
5860
- name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
5961
vlan:
6062
mode: access
6163
tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
6264
{% endfor %}
65+
{% set routes = [] %}
66+
{% for route in ctlplane_host_routes | default([], true) %}
67+
{% set _ = routes.append((route, neutron_physical_bridge_name)) %}
68+
{% endfor %}
69+
{% for network in nodeset_networks %}
70+
{% for route in lookup('vars', networks_lower[network] ~ '_host_routes') | default([], true) %}
71+
{% set _ = routes.append((route, "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id'))) %}
72+
{% endfor %}
73+
{% endfor %}
74+
{% if routes %}
6375
routes:
6476
config:
65-
- destination: {{ ctlplane_host_routes.ip_netmask }}
66-
next-hop-address: {{ ctlplane_host_routes.next_hop }}
67-
next-hop-interface: {{ neutron_physical_bridge_name }}
77+
{% for route, iface in routes %}
78+
- destination: {{ route.destination | default(route.ip_netmask, true) }}
79+
next-hop-address: {{ route.nexthop | default(route.next_hop, true) }}
80+
next-hop-interface: {{ iface }}
81+
{% endfor %}
82+
{% endif %}
6883
# edpm_network_config - nmstate
6984
edpm_network_config_tool: 'nmstate'
7085
# These vars are for the network config templates themselves and are
7186
# considered EDPM network defaults.
7287
neutron_physical_bridge_name: br-ex
73-
neutron_public_interface_name: eth0
7488
# edpm_nodes_validation
7589
edpm_nodes_validation_validate_controllers_icmp: false
7690
edpm_nodes_validation_validate_gateway_icmp: false
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kustomize.config.k8s.io/v1alpha1
2+
kind: Component
3+
4+
namespace: openstack
5+
6+
components:
7+
- ../baremetal
8+
9+
resources:
10+
- values.yaml
11+
12+
replacements:
13+
# OpenStackDataPlaneNodeSet customizations
14+
- source:
15+
kind: DataPlaneConfig
16+
name: edpm-nmstate-baremetal-values
17+
fieldPath: data.nodeset.nodetemplate.ansible.vars
18+
targets:
19+
- select:
20+
kind: OpenStackDataPlaneNodeSet
21+
fieldPaths:
22+
- spec.nodeTemplate.ansible.ansibleVars
23+
options:
24+
create: true
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# local-config: referenced, but not emitted by kustomize
2+
apiVersion: v1
3+
kind: DataPlaneConfig
4+
metadata:
5+
name: edpm-nmstate-baremetal-values
6+
annotations:
7+
config.kubernetes.io/local-config: "true"
8+
data:
9+
nodeset:
10+
nodetemplate:
11+
ansible:
12+
vars:
13+
edpm_network_config_hide_sensitive_logs: false
14+
edpm_network_config_template: |
15+
---
16+
{% set mtu_list = [ctlplane_mtu] %}
17+
{% for network in nodeset_networks %}
18+
{% set _ = mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) %}
19+
{%- endfor %}
20+
{% set min_viable_mtu = mtu_list | max %}
21+
dns-resolver:
22+
config:
23+
search: {{ dns_search_domains }}
24+
server: {{ ctlplane_dns_nameservers }}
25+
interfaces:
26+
- name: nic1
27+
type: ethernet
28+
state: up
29+
mtu: {{ min_viable_mtu }}
30+
- name: {{ neutron_physical_bridge_name }}
31+
type: ovs-interface
32+
state: up
33+
mtu: {{ min_viable_mtu }}
34+
ipv4:
35+
enabled: true
36+
address:
37+
- ip: {{ ctlplane_ip }}
38+
prefix-length: {{ ctlplane_cidr }}
39+
{% for network in nodeset_networks %}
40+
- name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
41+
type: ovs-interface
42+
state: up
43+
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
44+
ipv4:
45+
enabled: true
46+
address:
47+
- ip: {{ lookup('vars', networks_lower[network] ~ '_ip') }}
48+
prefix-length: {{ lookup('vars', networks_lower[network] ~ '_cidr') }}
49+
{% endfor %}
50+
- name: {{ neutron_physical_bridge_name }}
51+
type: ovs-bridge
52+
state: up
53+
bridge:
54+
options:
55+
fail-mode: standalone
56+
port:
57+
- name: nic1
58+
- name: {{ neutron_physical_bridge_name }}
59+
{% for network in nodeset_networks %}
60+
- name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
61+
vlan:
62+
mode: access
63+
tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
64+
{% endfor %}
65+
{% set routes = [] %}
66+
{% for route in ctlplane_host_routes | default([], true) %}
67+
{% set _ = routes.append((route, neutron_physical_bridge_name)) %}
68+
{% endfor %}
69+
{% for network in nodeset_networks %}
70+
{% for route in lookup('vars', networks_lower[network] ~ '_host_routes') | default([], true) %}
71+
{% set _ = routes.append((route, "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id'))) %}
72+
{% endfor %}
73+
{% endfor %}
74+
{% if routes %}
75+
routes:
76+
config:
77+
{% for route, iface in routes %}
78+
- destination: {{ route.destination | default(route.ip_netmask, true) }}
79+
next-hop-address: {{ route.nexthop | default(route.next_hop, true) }}
80+
next-hop-interface: {{ iface }}
81+
{% endfor %}
82+
{% endif %}
83+
# edpm_network_config - nmstate
84+
edpm_network_config_tool: 'nmstate'
85+
# These vars are for the network config templates themselves and are
86+
# considered EDPM network defaults.
87+
neutron_physical_bridge_name: br-ex
88+
# edpm_nodes_validation
89+
edpm_nodes_validation_validate_controllers_icmp: false
90+
edpm_nodes_validation_validate_gateway_icmp: false
91+
ctlplane_dns_nameservers:
92+
- 192.168.122.1
93+
dns_search_domains: []
94+
gather_facts: false
95+
enable_debug: false
96+
# edpm firewall, change the allowed CIDR if needed
97+
edpm_sshd_configure_firewall: true
98+
edpm_sshd_allowed_ranges: ['192.168.111.0/24']
99+
# SELinux module
100+
edpm_selinux_mode: enforcing
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
{% set mtu_list = [ctlplane_mtu] %}
3+
{% for network in nodeset_networks %}
4+
{% set _ = mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) %}
5+
{%- endfor %}
6+
{% set min_viable_mtu = mtu_list | max %}
7+
dns-resolver:
8+
config:
9+
search: {{ dns_search_domains }}
10+
server: {{ ctlplane_dns_nameservers }}
11+
interfaces:
12+
- name: nic1
13+
type: ethernet
14+
state: up
15+
mtu: {{ min_viable_mtu }}
16+
- name: {{ neutron_physical_bridge_name }}
17+
type: ovs-interface
18+
state: up
19+
mtu: {{ min_viable_mtu }}
20+
ipv4:
21+
enabled: true
22+
address:
23+
- ip: {{ ctlplane_ip }}
24+
prefix-length: {{ ctlplane_cidr }}
25+
{% for network in nodeset_networks %}
26+
- name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
27+
type: ovs-interface
28+
state: up
29+
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
30+
ipv4:
31+
enabled: true
32+
address:
33+
- ip: {{ lookup('vars', networks_lower[network] ~ '_ip') }}
34+
prefix-length: {{ lookup('vars', networks_lower[network] ~ '_cidr') }}
35+
{% endfor %}
36+
- name: {{ neutron_physical_bridge_name }}
37+
type: ovs-bridge
38+
state: up
39+
bridge:
40+
options:
41+
fail-mode: standalone
42+
port:
43+
- name: nic1
44+
- name: {{ neutron_physical_bridge_name }}
45+
{% for network in nodeset_networks %}
46+
- name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
47+
vlan:
48+
mode: access
49+
tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
50+
{% endfor %}
51+
{% set routes = [] %}
52+
{% for route in ctlplane_host_routes | default([], true) %}
53+
{% set _ = routes.append((route, neutron_physical_bridge_name)) %}
54+
{% endfor %}
55+
{% for network in nodeset_networks %}
56+
{% for route in lookup('vars', networks_lower[network] ~ '_host_routes') | default([], true) %}
57+
{% set _ = routes.append((route, "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id'))) %}
58+
{% endfor %}
59+
{% endfor %}
60+
{% if routes %}
61+
routes:
62+
config:
63+
{% for route, iface in routes %}
64+
- destination: {{ route.destination | default(route.ip_netmask, true) }}
65+
next-hop-address: {{ route.nexthop | default(route.next_hop, true) }}
66+
next-hop-interface: {{ iface }}
67+
{% endfor %}
68+
{% endif %}

0 commit comments

Comments
 (0)