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 7, 2023
1 parent bf3608a commit 1d9329b
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 102 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
19 changes: 0 additions & 19 deletions api/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,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 +98,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,15 +143,6 @@ 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"}

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
13 changes: 0 additions & 13 deletions docs/openstack_dataplanenodeset.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* [AnsibleEESpec](#ansibleeespec)
* [AnsibleOpts](#ansibleopts)
* [DeployStrategySection](#deploystrategysection)
* [NetworkConfigSection](#networkconfigsection)
* [NodeSection](#nodesection)
* [NodeTemplate](#nodetemplate)
* [OpenStackDataPlaneNodeSetList](#openstackdataplanenodesetlist)
Expand Down Expand Up @@ -58,24 +57,13 @@ DeployStrategySection for fields controlling the deployment

[Back to Custom Resources](#custom-resources)

#### NetworkConfigSection

NetworkConfigSection is a specification of the Network configuration details

| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| template | Template - Contains a Ansible j2 nic config template to use when applying node network configuration | string | false |

[Back to Custom Resources](#custom-resources)

#### NodeSection

NodeSection defines the top level attributes inherited by nodes in the CR.

| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| hostName | HostName - node name | string | false |
| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | true |
| networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false |
| managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false |
| ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false |
Expand All @@ -94,7 +82,6 @@ NodeTemplate is a specification of the node attributes that override top level a
| ansibleSSHPrivateKeySecret | AnsibleSSHPrivateKeySecret Private SSH Key secret containing private SSH key for connecting to node. Must be of the form: Secret.data.ssh-privatekey: <base64 encoded private key contents> <https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets> | string | false |
| nodes | Nodes - Map of Node Names and node specific data. Values here override defaults in the upper level section. | map[string][NodeSection](#nodesection) | true |
| networkAttachments | NetworkAttachments is a list of NetworkAttachment resource names to pass to the ansibleee resource which allows to connect the ansibleee runner to the given network | []string | false |
| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | false |
| networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false |
| managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false |
| ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false |
Expand Down
13 changes: 0 additions & 13 deletions docs/openstack_dataplaneservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* [AnsibleEESpec](#ansibleeespec)
* [AnsibleOpts](#ansibleopts)
* [DeployStrategySection](#deploystrategysection)
* [NetworkConfigSection](#networkconfigsection)
* [NodeSection](#nodesection)
* [NodeTemplate](#nodetemplate)
* [KubeService](#kubeservice)
Expand Down Expand Up @@ -59,24 +58,13 @@ DeployStrategySection for fields controlling the deployment

[Back to Custom Resources](#custom-resources)

#### NetworkConfigSection

NetworkConfigSection is a specification of the Network configuration details

| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| template | Template - Contains a Ansible j2 nic config template to use when applying node network configuration | string | false |

[Back to Custom Resources](#custom-resources)

#### NodeSection

NodeSection defines the top level attributes inherited by nodes in the CR.

| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| hostName | HostName - node name | string | false |
| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | true |
| networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false |
| managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false |
| ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false |
Expand All @@ -95,7 +83,6 @@ NodeTemplate is a specification of the node attributes that override top level a
| ansibleSSHPrivateKeySecret | AnsibleSSHPrivateKeySecret Private SSH Key secret containing private SSH key for connecting to node. Must be of the form: Secret.data.ssh-privatekey: <base64 encoded private key contents> <https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets> | string | false |
| nodes | Nodes - Map of Node Names and node specific data. Values here override defaults in the upper level section. | map[string][NodeSection](#nodesection) | true |
| networkAttachments | NetworkAttachments is a list of NetworkAttachment resource names to pass to the ansibleee resource which allows to connect the ansibleee runner to the given network | []string | false |
| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | false |
| networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false |
| managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false |
| ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false |
Expand Down
20 changes: 0 additions & 20 deletions pkg/deployment/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper,
host.Vars[entry+"_host_routes"] = res.Routes
dnsSearchDomains = append(dnsSearchDomains, res.DNSDomain)
}
networkConfig := getAnsibleNetworkConfig(instance, nodeName)

if networkConfig.Template != "" {
host.Vars["edpm_network_config_template"] = NicConfigTemplateFile
}

host.Vars["ansible_user"] = getAnsibleUser(instance, nodeName)
host.Vars["ansible_port"] = getAnsiblePort(instance, nodeName)
Expand Down Expand Up @@ -134,7 +129,6 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper,
}
secretData := map[string]string{
"inventory": string(invData),
"network": string(instance.Spec.NodeTemplate.NetworkConfig.Template),
}
secretName := fmt.Sprintf("dataplanenodeset-%s", instance.Name)
template := []utils.Template{
Expand Down Expand Up @@ -215,14 +209,6 @@ func getAnsibleManagementNetwork(
return instance.Spec.NodeTemplate.ManagementNetwork
}

// getAnsibleNetworkConfig returns a JSON string value from the template unless it is set in the node
func getAnsibleNetworkConfig(instance *dataplanev1.OpenStackDataPlaneNodeSet, nodeName string) dataplanev1.NetworkConfigSection {
if instance.Spec.NodeTemplate.Nodes[nodeName].NetworkConfig.Template != "" {
return instance.Spec.NodeTemplate.Nodes[nodeName].NetworkConfig
}
return instance.Spec.NodeTemplate.NetworkConfig
}

// getAnsibleNetworks returns a JSON string mapping fixedIP and/or network name to their valules
func getAnsibleNetworks(instance *dataplanev1.OpenStackDataPlaneNodeSet, nodeName string) []infranetworkv1.IPSetNetwork {
if len(instance.Spec.NodeTemplate.Nodes[nodeName].Networks) > 0 {
Expand Down Expand Up @@ -296,9 +282,6 @@ func resolveAnsibleVars(nodeTemplate *dataplanev1.NodeTemplate, host *ansible.Ho
if nodeTemplate.ManagementNetwork != "" {
ansibleVarsData["management_network"] = nodeTemplate.ManagementNetwork
}
if nodeTemplate.NetworkConfig.Template != "" {
ansibleVarsData["edpm_network_config_template"] = NicConfigTemplateFile
}
if len(nodeTemplate.Networks) > 0 {
ansibleVarsData["networks"] = nodeTemplate.Networks
}
Expand Down Expand Up @@ -340,9 +323,6 @@ func resolveNodeAnsibleVars(node *dataplanev1.NodeSection, host *ansible.Host, g
if node.ManagementNetwork != "" {
ansibleVarsData["management_network"] = node.ManagementNetwork
}
if node.NetworkConfig.Template != "" {
ansibleVarsData["edpm_network_config_template"] = NicConfigTemplateFile
}
if len(node.Networks) > 0 {
ansibleVarsData["networks"] = node.Networks
}
Expand Down

0 comments on commit 1d9329b

Please sign in to comment.