Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Remove NetworkConfig override handling
Browse files Browse the repository at this point in the history
This change removes the CRD level override for network config files.
Instead, this allows us to use the Ansible variable directly to set any
require network config customizations.

Depends-On: openstack-k8s-operators/edpm-ansible#243

Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Sep 11, 2023
1 parent 825e933 commit 5abce59
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 161 deletions.
10 changes: 0 additions & 10 deletions api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,6 @@ spec:
items:
type: string
type: array
networkConfig:
properties:
template:
type: string
type: object
networkData:
properties:
name:
Expand Down Expand Up @@ -1833,11 +1828,6 @@ spec:
type: string
managementNetwork:
type: string
networkConfig:
properties:
template:
type: string
type: object
networkData:
properties:
name:
Expand Down
38 changes: 21 additions & 17 deletions api/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"encoding/json"
"reflect"

infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/storage"
Expand Down Expand Up @@ -52,11 +53,6 @@ type NodeSection struct {
// +kubebuilder:validation:Optional
HostName string `json:"hostName,omitempty"`

// NetworkConfig - Network configuration details. Contains os-net-config
// related properties.
// +kubebuilder:validation:Optional
NetworkConfig NetworkConfigSection `json:"networkConfig"`

// Networks - Instance networks
// +kubebuilder:validation:Optional
Networks []infranetworkv1.IPSetNetwork `json:"networks,omitempty"`
Expand Down Expand Up @@ -103,11 +99,6 @@ type NodeTemplate struct {
// +kubebuilder:validation:Optional
NetworkAttachments []string `json:"networkAttachments,omitempty"`

// NetworkConfig - Network configuration details. Contains os-net-config
// related properties.
// +kubebuilder:validation:Optional
NetworkConfig NetworkConfigSection `json:"networkConfig,omitempty"`

// Networks - Instance networks
// +kubebuilder:validation:Optional
Networks []infranetworkv1.IPSetNetwork `json:"networks,omitempty"`
Expand Down Expand Up @@ -153,13 +144,26 @@ type DeployStrategySection struct {
AnsibleSkipTags string `json:"ansibleSkipTags,omitempty"`
}

// NetworkConfigSection is a specification of the Network configuration details
type NetworkConfigSection struct {

// Template - Contains a Ansible j2 nic config template to use when applying node
// network configuration
// +kubebuilder:validation:Optional
Template string `json:"template,omitempty" yaml:"template,omitempty"`
// UniqueSpecFields - the array of fields that must be unique between role and nodes
var UniqueSpecFields = []string{"NetworkAttachments"}

// AssertUniquenessBetween - compare specs for uniqueness
func AssertUniquenessBetween(spec interface{}, otherSpec interface{}, suffix string) []string {
vSpec := reflect.ValueOf(spec)
vOtherSpec := reflect.ValueOf(otherSpec)

var errorMsgs []string
for _, field := range UniqueSpecFields {
value := vSpec.FieldByName(field)
otherValue := vOtherSpec.FieldByName(field)
if value.IsZero() || otherValue.IsZero() {
continue
}
if !reflect.DeepEqual(value.Interface(), otherValue.Interface()) {
errorMsgs = append(errorMsgs, field+" mismatch between "+suffix)
}
}
return errorMsgs
}

// AnsibleEESpec is a specification of the ansible EE attributes
Expand Down
17 changes: 0 additions & 17 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,6 @@ spec:
items:
type: string
type: array
networkConfig:
properties:
template:
type: string
type: object
networkData:
properties:
name:
Expand Down Expand Up @@ -1833,11 +1828,6 @@ spec:
type: string
managementNetwork:
type: string
networkConfig:
properties:
template:
type: string
type: object
networkData:
properties:
name:
Expand Down
34 changes: 33 additions & 1 deletion config/samples/dataplane_v1beta1_openstackdataplanenodeset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,39 @@ spec:
# Default nic config template for a EDPM compute node
# These vars are edpm_network_config role vars
edpm_network_config_hide_sensitive_logs: false
edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2
edpm_network_config_template: |
---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ min_viable_mtu }}
use_dhcp: false
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
routes: {{ ctlplane_host_routes }}
members:
- type: interface
name: nic1
mtu: {{ min_viable_mtu }}
# force the MAC address of the bridge to this interface
primary: true
{% for network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endfor %}
# These vars are for the network config templates themselves and are
# considered EDPM network defaults.
neutron_physical_bridge_name: br-ex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,38 @@ spec:
# edpm_network_config
# Default nic config template for a EDPM compute node
# These vars are edpm_network_config role vars
edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2
edpm_network_config_template: |
---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ min_viable_mtu }}
use_dhcp: false
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
routes: {{ ctlplane_host_routes }}
members:
- type: interface
name: nic1
mtu: {{ min_viable_mtu }}
# force the MAC address of the bridge to this interface
primary: true
{% for network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endfor %}
edpm_network_config_hide_sensitive_logs: false

# These vars are for the network config templates themselves and are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,38 @@ spec:
# Default nic config template for a EDPM compute node
# These vars are edpm_network_config role vars
edpm_network_config_hide_sensitive_logs: false
edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2
edpm_network_config_template: |
---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ min_viable_mtu }}
use_dhcp: false
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
routes: {{ ctlplane_host_routes }}
members:
- type: interface
name: nic1
mtu: {{ min_viable_mtu }}
# force the MAC address of the bridge to this interface
primary: true
{% for network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endfor %}
# These vars are for the network config templates themselves and are
# considered EDPM network defaults.
neutron_physical_bridge_name: br-ex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: dataplane.openstack.org/v1beta1
kind: OpenStackDataPlaneNodeSet
metadata:
name: openstack-edpm-ceph
name: openstack-edpm
spec:
env:
- name: ANSIBLE_FORCE_COLOR
Expand Down Expand Up @@ -67,7 +67,39 @@ spec:
# edpm_network_config
# Default nic config template for a EDPM compute node
# These vars are edpm_network_config role vars
edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2
edpm_network_config_template: |
---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ min_viable_mtu }}
use_dhcp: false
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
routes: {{ ctlplane_host_routes }}
members:
- type: interface
name: nic1
mtu: {{ min_viable_mtu }}
# force the MAC address of the bridge to this interface
primary: true
{% for network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endfor %}
edpm_network_config_hide_sensitive_logs: false
#
# These vars are for the network config templates themselves and are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,38 @@ spec:
# edpm_network_config
# Default nic config template for a EDPM compute node
# These vars are edpm_network_config role vars
edpm_network_config_template: /runner/network/nic-config-template
edpm_network_config_template: |
---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ min_viable_mtu }}
use_dhcp: false
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
routes: {{ ctlplane_host_routes }}
members:
- type: interface
name: nic1
mtu: {{ min_viable_mtu }}
# force the MAC address of the bridge to this interface
primary: true
{% for network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endfor %}
edpm_network_config_hide_sensitive_logs: false
edpm_network_config_update: false
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,38 @@ spec:
# edpm_network_config
# Default nic config template for a EDPM compute node
# These vars are edpm_network_config role vars
edpm_network_config_template: |
---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: ovs_bridge
name: {{ neutron_physical_bridge_name }}
mtu: {{ min_viable_mtu }}
use_dhcp: false
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
routes: {{ ctlplane_host_routes }}
members:
- type: interface
name: nic1
mtu: {{ min_viable_mtu }}
# force the MAC address of the bridge to this interface
primary: true
{% for network in role_networks %}
- type: vlan
mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }}
vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }}
addresses:
- ip_netmask:
{{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }}
routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }}
{% endfor %}
edpm_network_config_hide_sensitive_logs: false
# These vars are for the network config templates themselves and are
# considered EDPM network defaults.
Expand Down
Loading

0 comments on commit 5abce59

Please sign in to comment.