-
Notifications
You must be signed in to change notification settings - Fork 37
Support multiple networks in OpenTofu configurations #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c93d9be
support multiple networks for control node
sjpb ad54226
support multiple networks for all nodes w/ inventory output
sjpb 652edb1
simplify control node definition and access IP
sjpb 619436d
add network docs
sjpb 83a0a85
Apply suggestions from code review
sjpb 040c2bc
use first network as access network and support extra_networks only
sjpb a381a43
Merge branch 'main' into feat/tf-multiple-networks
sjpb cd423b5
fixup control node for access network changes
sjpb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Networking | ||
|
||
The default OpenTofu configurations in the appliance do not provision networks, | ||
subnets or associated infrastructure such as routers. The requirements are that: | ||
1. At least one network exists. | ||
2. The first network defined spans all nodes, referred to as the "access network". | ||
3. Only one subnet per network is attached to nodes. | ||
4. At least one network on each node provides outbound internet access (either | ||
m-bull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
directly, or via a proxy). | ||
|
||
Futhermore, it is recommended that the deploy host has an interface on the | ||
access network. While it is possible to e.g. use a floating IP on a login node | ||
as an SSH proxy to access the other nodes, this can create problems in recovering | ||
the cluster if the login node is unavailable and can make Ansible problems harder | ||
to debug. | ||
|
||
This page describes supported configurations and how to implement them using | ||
the OpenTofu variables. These will normally be set in | ||
`environments/site/tofu/terraform.tfvars` for the site base environment. If they | ||
need to be overriden for specific environments, this can be done via an OpenTofu | ||
module as discussed [here](./production.md). | ||
|
||
Note that if an OpenStack subnet has a gateway IP defined then nodes with ports | ||
attached to that subnet will get a default route set via that gateway. | ||
|
||
## Single network | ||
This is the simplest possible configuration. A single network and subnet is | ||
used for all nodes. The subnet provides outbound internet access via the default | ||
route defined by the subnet gateway (often an OpenStack router to an external | ||
network). | ||
|
||
```terraform | ||
cluster_networks = [ | ||
{ | ||
network = "netA" | ||
subnet = "subnetA" | ||
} | ||
] | ||
... | ||
``` | ||
|
||
## Multiple homogenous networks | ||
This is similar to the above, except each node has multiple networks. The first | ||
network, "netA" is the access network. Note that only one subnet must have a | ||
gateway defined, else default routes via both subnets will be present causing | ||
routing problems. It also shows the second network (netB) using direct-type | ||
vNICs for RDMA. | ||
|
||
```terraform | ||
cluster_networks = [ | ||
{ | ||
network = "netA" | ||
subnet = "subnetA" | ||
}, | ||
{ | ||
network = "netB" | ||
subnet = "subnetB" | ||
}, | ||
] | ||
|
||
vnic_types = { | ||
netB = "direct" | ||
} | ||
... | ||
``` | ||
|
||
|
||
## Additional networks on some nodes | ||
|
||
This example shows how to modify variables for specific node groups. In this | ||
case a baremetal node group has a second network attached. As above, only a | ||
single subnet can have a gateway IP. | ||
|
||
```terraform | ||
cluster_networks = [ | ||
{ | ||
network = "netA" | ||
subnet = "subnetA" | ||
sjpb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
] | ||
|
||
compute = { | ||
general = { | ||
nodes = ["general-0", "general-1"] | ||
} | ||
baremetal = { | ||
sjpb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
nodes = ["baremetal-0", "baremetal-1"] | ||
extra_networks = [ | ||
{ | ||
network = "netB" | ||
subnet = "subnetB" | ||
} | ||
] | ||
vnic_types = { | ||
netA = "baremetal" | ||
netB = "baremetal" | ||
... | ||
} | ||
} | ||
} | ||
... | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
environments/skeleton/{{cookiecutter.environment}}/tofu/network.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
environments/skeleton/{{cookiecutter.environment}}/tofu/node_group/network.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
data "openstack_networking_network_v2" "network" { | ||
|
||
for_each = {for net in var.networks: net.network => net} | ||
|
||
name = each.value.network | ||
} | ||
|
||
data "openstack_networking_subnet_v2" "subnet" { | ||
|
||
for_each = {for net in var.networks: net.network => net} | ||
|
||
name = each.value.subnet | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.