diff --git a/config/samples/dataplane/nmstate/kustomization.yaml b/config/samples/dataplane/nmstate/kustomization.yaml index adc0023702..54491db6a2 100644 --- a/config/samples/dataplane/nmstate/kustomization.yaml +++ b/config/samples/dataplane/nmstate/kustomization.yaml @@ -22,21 +22,3 @@ replacements: - spec.nodeTemplate.ansible.ansibleVars options: create: true - -patches: -- target: - kind: OpenStackDataPlaneNodeSet - name: .* - patch: |- - - op: copy - from: /spec/nodes/edpm-compute-0 - path: /spec/nodes/edpm-compute-1 - - op: replace - path: /spec/nodes/edpm-compute-1/ansible/ansibleHost - value: 192.168.122.101 - - op: replace - path: /spec/nodes/edpm-compute-1/hostName - value: edpm-compute-1 - - op: replace - path: /spec/nodes/edpm-compute-1/networks/0/fixedIP - value: 192.168.122.101 diff --git a/config/samples/dataplane/nmstate/values.yaml b/config/samples/dataplane/nmstate/values.yaml index 064d6e1b3b..034b943f3b 100644 --- a/config/samples/dataplane/nmstate/values.yaml +++ b/config/samples/dataplane/nmstate/values.yaml @@ -23,9 +23,10 @@ data: search: {{ dns_search_domains }} server: {{ ctlplane_dns_nameservers }} interfaces: - - name: {{ neutron_public_interface_name }} + - name: nic1 type: ethernet state: up + mtu: {{ min_viable_mtu }} - name: {{ neutron_physical_bridge_name }} type: ovs-interface state: up @@ -48,11 +49,12 @@ data: {% endfor %} - name: {{ neutron_physical_bridge_name }} type: ovs-bridge + state: up bridge: options: fail-mode: standalone port: - - name: {{ neutron_public_interface_name }} + - name: nic1 - name: {{ neutron_physical_bridge_name }} {% for network in nodeset_networks %} - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} @@ -60,17 +62,29 @@ data: mode: access tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} {% endfor %} + {% set routes = [] %} + {% for route in ctlplane_host_routes | default([], true) %} + {% set _ = routes.append((route, neutron_physical_bridge_name)) %} + {% endfor %} + {% for network in nodeset_networks %} + {% for route in lookup('vars', networks_lower[network] ~ '_host_routes') | default([], true) %} + {% set _ = routes.append((route, "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id'))) %} + {% endfor %} + {% endfor %} + {% if routes %} routes: config: - - destination: {{ ctlplane_host_routes.ip_netmask }} - next-hop-address: {{ ctlplane_host_routes.next_hop }} - next-hop-interface: {{ neutron_physical_bridge_name }} + {% for route, iface in routes %} + - destination: {{ route.destination | default(route.ip_netmask, true) }} + next-hop-address: {{ route.nexthop | default(route.next_hop, true) }} + next-hop-interface: {{ iface }} + {% endfor %} + {% endif %} # edpm_network_config - nmstate edpm_network_config_tool: 'nmstate' # These vars are for the network config templates themselves and are # considered EDPM network defaults. neutron_physical_bridge_name: br-ex - neutron_public_interface_name: eth0 # edpm_nodes_validation edpm_nodes_validation_validate_controllers_icmp: false edpm_nodes_validation_validate_gateway_icmp: false diff --git a/config/samples/dataplane/nmstate_baremetal/kustomization.yaml b/config/samples/dataplane/nmstate_baremetal/kustomization.yaml new file mode 100644 index 0000000000..55d483a37b --- /dev/null +++ b/config/samples/dataplane/nmstate_baremetal/kustomization.yaml @@ -0,0 +1,24 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +namespace: openstack + +components: +- ../baremetal + +resources: + - values.yaml + +replacements: +# OpenStackDataPlaneNodeSet customizations +- source: + kind: DataPlaneConfig + name: edpm-nmstate-baremetal-values + fieldPath: data.nodeset.nodetemplate.ansible.vars + targets: + - select: + kind: OpenStackDataPlaneNodeSet + fieldPaths: + - spec.nodeTemplate.ansible.ansibleVars + options: + create: true diff --git a/config/samples/dataplane/nmstate_baremetal/values.yaml b/config/samples/dataplane/nmstate_baremetal/values.yaml new file mode 100644 index 0000000000..7ac6a5511d --- /dev/null +++ b/config/samples/dataplane/nmstate_baremetal/values.yaml @@ -0,0 +1,100 @@ +# local-config: referenced, but not emitted by kustomize +apiVersion: v1 +kind: DataPlaneConfig +metadata: + name: edpm-nmstate-baremetal-values + annotations: + config.kubernetes.io/local-config: "true" +data: + nodeset: + nodetemplate: + ansible: + vars: + edpm_network_config_hide_sensitive_logs: false + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in nodeset_networks %} + {% set _ = mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) %} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + dns-resolver: + config: + search: {{ dns_search_domains }} + server: {{ ctlplane_dns_nameservers }} + interfaces: + - name: nic1 + type: ethernet + state: up + mtu: {{ min_viable_mtu }} + - name: {{ neutron_physical_bridge_name }} + type: ovs-interface + state: up + mtu: {{ min_viable_mtu }} + ipv4: + enabled: true + address: + - ip: {{ ctlplane_ip }} + prefix-length: {{ ctlplane_cidr }} + {% for network in nodeset_networks %} + - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + type: ovs-interface + state: up + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + ipv4: + enabled: true + address: + - ip: {{ lookup('vars', networks_lower[network] ~ '_ip') }} + prefix-length: {{ lookup('vars', networks_lower[network] ~ '_cidr') }} + {% endfor %} + - name: {{ neutron_physical_bridge_name }} + type: ovs-bridge + state: up + bridge: + options: + fail-mode: standalone + port: + - name: nic1 + - name: {{ neutron_physical_bridge_name }} + {% for network in nodeset_networks %} + - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + vlan: + mode: access + tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + {% endfor %} + {% set routes = [] %} + {% for route in ctlplane_host_routes | default([], true) %} + {% set _ = routes.append((route, neutron_physical_bridge_name)) %} + {% endfor %} + {% for network in nodeset_networks %} + {% for route in lookup('vars', networks_lower[network] ~ '_host_routes') | default([], true) %} + {% set _ = routes.append((route, "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id'))) %} + {% endfor %} + {% endfor %} + {% if routes %} + routes: + config: + {% for route, iface in routes %} + - destination: {{ route.destination | default(route.ip_netmask, true) }} + next-hop-address: {{ route.nexthop | default(route.next_hop, true) }} + next-hop-interface: {{ iface }} + {% endfor %} + {% endif %} + # edpm_network_config - nmstate + edpm_network_config_tool: 'nmstate' + # These vars are for the network config templates themselves and are + # considered EDPM network defaults. + neutron_physical_bridge_name: br-ex + # edpm_nodes_validation + edpm_nodes_validation_validate_controllers_icmp: false + edpm_nodes_validation_validate_gateway_icmp: false + ctlplane_dns_nameservers: + - 192.168.122.1 + dns_search_domains: [] + gather_facts: false + enable_debug: false + # edpm firewall, change the allowed CIDR if needed + edpm_sshd_configure_firewall: true + edpm_sshd_allowed_ranges: ['192.168.111.0/24'] + # SELinux module + edpm_selinux_mode: enforcing diff --git a/config/samples/nic-config-samples/nmstate/single_nic_vlans/single_nic_vlans.j2 b/config/samples/nic-config-samples/nmstate/single_nic_vlans/single_nic_vlans.j2 new file mode 100644 index 0000000000..155772bdf5 --- /dev/null +++ b/config/samples/nic-config-samples/nmstate/single_nic_vlans/single_nic_vlans.j2 @@ -0,0 +1,68 @@ +--- +{% set mtu_list = [ctlplane_mtu] %} +{% for network in nodeset_networks %} +{% set _ = mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) %} +{%- endfor %} +{% set min_viable_mtu = mtu_list | max %} +dns-resolver: + config: + search: {{ dns_search_domains }} + server: {{ ctlplane_dns_nameservers }} +interfaces: + - name: nic1 + type: ethernet + state: up + mtu: {{ min_viable_mtu }} + - name: {{ neutron_physical_bridge_name }} + type: ovs-interface + state: up + mtu: {{ min_viable_mtu }} + ipv4: + enabled: true + address: + - ip: {{ ctlplane_ip }} + prefix-length: {{ ctlplane_cidr }} +{% for network in nodeset_networks %} + - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + type: ovs-interface + state: up + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + ipv4: + enabled: true + address: + - ip: {{ lookup('vars', networks_lower[network] ~ '_ip') }} + prefix-length: {{ lookup('vars', networks_lower[network] ~ '_cidr') }} +{% endfor %} + - name: {{ neutron_physical_bridge_name }} + type: ovs-bridge + state: up + bridge: + options: + fail-mode: standalone + port: + - name: nic1 + - name: {{ neutron_physical_bridge_name }} +{% for network in nodeset_networks %} + - name: {{ "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + vlan: + mode: access + tag: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} +{% endfor %} +{% set routes = [] %} +{% for route in ctlplane_host_routes | default([], true) %} +{% set _ = routes.append((route, neutron_physical_bridge_name)) %} +{% endfor %} +{% for network in nodeset_networks %} +{% for route in lookup('vars', networks_lower[network] ~ '_host_routes') | default([], true) %} +{% set _ = routes.append((route, "vlan" ~ lookup('vars', networks_lower[network] ~ '_vlan_id'))) %} +{% endfor %} +{% endfor %} +{% if routes %} +routes: + config: +{% for route, iface in routes %} + - destination: {{ route.destination | default(route.ip_netmask, true) }} + next-hop-address: {{ route.nexthop | default(route.next_hop, true) }} + next-hop-interface: {{ iface }} +{% endfor %} +{% endif %}