Skip to content

Commit 072c057

Browse files
authored
Merge pull request #377 from etiennedub/incus_cluster
Incus cluster support
2 parents 2df3f2c + 3de12af commit 072c057

4 files changed

Lines changed: 54 additions & 8 deletions

File tree

docs/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,10 @@ For more information on these attributes, refer to
611611
available models per region
612612
- `gpus`: number of GPUs of the `gpu_type` model to attach to the instance
613613
614+
##### Incus
615+
616+
- `target`: name of the [specific cluster member](https://linuxcontainers.org/incus/docs/main/howto/cluster_manage_instance/#launch-an-instance-on-a-specific-cluster-member) to deploy the instance. **Only use with Incus cluster.**
617+
614618
#### 4.7.3 Post build modification effect
615619
616620
Modifying any part of the map after the cluster is built will only affect
@@ -1157,6 +1161,22 @@ that will be used to create the instance root disk and the shared filesystems.
11571161
11581162
**Post build modification effect**: rebuild all instance and filesystems.
11591163
1164+
### network_type (optional)
1165+
1166+
**default value**: `"bridge"`
1167+
1168+
Indicates the type of [Incus network](https://linuxcontainers.org/incus/docs/main/howto/network_create/#network-types).
1169+
For OVN, the host must support the OVN network.
1170+
1171+
**Possible values**: 'ovn' or 'bridge'
1172+
1173+
### ovn_uplink_network (optional)
1174+
**default value**: `"UPLINK"`
1175+
1176+
[Uplink bridge network](https://linuxcontainers.org/incus/docs/main/howto/network_ovn_setup/#set-up-an-incus-cluster-on-ovn) configured with the `ipv4.ovn.ranges` option.
1177+
1178+
**Only used for OVN network**
1179+
11601180
## 6. DNS Configuration
11611181
11621182
Some functionalities in Magic Castle require the registration of DNS records under the

incus/incus.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,20 @@ variable "shared_filesystems" {
1717
description = "Name of filesystems that need to be created and mounted in every instance"
1818
default = []
1919
}
20+
21+
variable "ovn_uplink_network" {
22+
default = "UPLINK"
23+
type = string
24+
description = "Uplink bridge network used by OVN. `ipv4.ovn.ranges` must be set"
25+
}
26+
27+
variable "network_type" {
28+
description = "Type of network to use (bridge or ovn)"
29+
type = string
30+
default = "bridge"
31+
32+
validation {
33+
condition = contains(["bridge", "ovn"], var.network_type)
34+
error_message = "network_type must be either 'bridge' or 'ovn'."
35+
}
36+
}

incus/infrastructure.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ resource "incus_instance" "instances" {
8585
image = try(incus_image.image[each.value.image].fingerprint, each.value.image)
8686
type = each.value.type
8787

88+
target = try(each.value.target, null)
89+
8890
config = {
8991
"cloud-init.user-data" = module.configuration.user_data[each.key]
9092
"security.privileged" = var.privileged
@@ -95,8 +97,7 @@ resource "incus_instance" "instances" {
9597
type = "nic"
9698

9799
properties = {
98-
nictype = "bridged"
99-
parent = incus_network.network.name
100+
network = incus_network.network.name
100101
}
101102
}
102103

@@ -141,8 +142,8 @@ resource "incus_instance" "instances" {
141142
}
142143

143144
locals {
144-
inventory = { for x, values in module.design.instances :
145-
x => {
145+
inventory = { for host, values in module.design.instances :
146+
host => {
146147
prefix = values.prefix
147148
tags = values.tags
148149
specs = values.specs

incus/network.tf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
resource "incus_network" "network" {
22
name = incus_project.project.name
33
project = incus_project.project.name
4-
config = {
5-
"ipv4.nat" = "true"
6-
"ipv6.address" = "none"
7-
}
4+
type = var.network_type
5+
config = merge(
6+
{
7+
"ipv6.address" = "none"
8+
"ipv4.nat" = true
9+
},
10+
var.network_type == "ovn" ? {
11+
"network" = var.ovn_uplink_network
12+
"dns.nameservers" = "1.1.1.1,1.0.0.1" # The default DNS server (incus) is inaccessible from OVN network
13+
} : {}
14+
)
815
}
16+

0 commit comments

Comments
 (0)