Skip to content

Commit 21e1514

Browse files
committed
WIP rework networking
1 parent 3786dd2 commit 21e1514

File tree

22 files changed

+95
-791
lines changed

22 files changed

+95
-791
lines changed

docs/getting_started/INTERNAL_DASHBOARDS.md

-19
This file was deleted.

docs/infrastructure/k3s/TROUBLESHOOTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ docker ps | grep k3d
1111
## I'm getting `Empty reply from server`
1212

1313
This means Traefik hasn't started yet. Make sure the deployment works.
14-

docs/infrastructure/networking/IP_RANGES.md

+8-41
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,15 @@
22

33
See [`lib/bolt/core/src/dep/terraform/net.rs`](../../../lib/bolt/core/src/dep/terraform/net.rs)
44

5-
## VLAN (Class B)
5+
## VLAN (Class A)
66

77
Allowed range:
88

9-
```
10-
172.16.0.0/12
11-
```
9+
| Name | Netmask | Subnet count | Node count |
10+
| ----------------------------- | ----------- | ------------ | ---------------- |
11+
| Entire VLAN | 10.0.0.0/8 | ~ | ~ |
12+
| Region | 10.0.0.0/16 | 256 | ~ |
13+
| Supporting services (GG, ATS) | 10.0.0.0/26 | 16 | 64 - 2 |
14+
| Job | 10.0.4.0/16 | ~ | 65536 - 1024 - 2 |
1215

13-
Region netmask: 18
14-
Allows for 64 regions
15-
16-
Pool netmask: 24
17-
Allows for 64 pools
18-
Allows for 254 hosts (since we can't allocate the network or broadcast address)
19-
20-
Pool netmasks can be flexible to take up multiple pools if there needs to be more than 254 nodes in a pool
21-
22-
## Nebula (Class A)
23-
24-
Allowed range:
25-
26-
```
27-
10.0.0.0/8
28-
```
29-
30-
### svc
31-
32-
Allowed range:
33-
34-
```
35-
10.0.0.0/12
36-
```
37-
38-
Region netmask: 18 (see above)
39-
Pool netmask: 24 (see above)
40-
41-
### job
42-
43-
```
44-
10.16.0.0/12
45-
```
46-
47-
Allows for 1,048,576 game server nodes
48-
49-
We'll build an IP address allocator for each node that gets created
16+
We can't allocate the network or broadcast address, so we subtract 2 from each node count.

infra/tests/standalone/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module "server" {
2020
provider = "linode"
2121
provider_region = "us-southeast"
2222
netnum = 0
23-
supports_vlan = false
2423
}
2524

2625
size = "g6-standard-4"

infra/tf/modules/generic_server/linode.tf

+6-15
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,14 @@ resource "linode_instance_config" "server_boot_config" {
9090
}
9191
}
9292

93-
dynamic "interface" {
94-
# TODO: Document why this is only included when has a VPC
95-
for_each = var.vpc != null ? [null] : []
96-
97-
content {
98-
purpose = "public"
99-
}
93+
interafce {
94+
purpose = "public"
10095
}
10196

102-
dynamic "interface" {
103-
for_each = var.vpc != null ? [null] : []
104-
105-
content {
106-
purpose = "vlan"
107-
label = "vpc"
108-
ipam_address = "${var.vpc.ip}/${var.vpc.netmask}"
109-
}
97+
interface {
98+
purpose = "vlan"
99+
label = "vpc"
100+
ipam_address = "${var.vpc.ip}/${var.region.netmask}"
110101
}
111102
}
112103

infra/tf/modules/generic_server/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ locals {
2626
],
2727
])
2828
}
29+

infra/tf/modules/generic_server/vars.tf

+4-11
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ variable "region" {
1212
type = object({
1313
provider = string
1414
provider_region = string
15-
netnum = number
16-
supports_vlan = bool
15+
vlan = object({
16+
address = string
17+
prefix_len = number
18+
})
1719
})
1820
}
1921

@@ -41,15 +43,6 @@ variable "volumes" {
4143
default = {}
4244
}
4345

44-
variable "vpc" {
45-
type = object({
46-
ip = string
47-
netmask = number
48-
})
49-
nullable = true
50-
default = null
51-
}
52-
5346
variable "firewall_inbound" {
5447
type = list(object({
5548
label = string

infra/tf/pools/servers.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ module "servers" {
1010
size = each.value.size
1111
label = each.value.name
1212
tags = each.value.tags
13-
vpc = var.pools[each.value.pool_id].vpc ? { ip = each.value.vpc_ip, netmask = var.svc_region_netmask } : null
13+
vlan = {
14+
ip = each.value.vlan_ip
15+
}
1416
volumes = each.value.volumes
1517
firewall_inbound = var.pools[each.value.pool_id].firewall_inbound
1618
}

infra/tf/pools/vars.tf

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ variable "regions" {
3333
id = string
3434
provider = string
3535
provider_region = string
36-
netnum = number
37-
supports_vlan = bool
38-
preferred_subnets = list(string)
36+
vlan = object({
37+
address = string
38+
prefix_len = number
39+
})
3940
}))
4041
}
4142

4243
# MARK: Pools
4344
variable "pools" {
4445
type = map(object({
4546
roles = list(string)
46-
vpc = bool
4747
tunnels = map(object({
4848
name = string
4949
service = string
@@ -76,6 +76,9 @@ variable "servers" {
7676
name = string
7777
size = string
7878
netnum = number
79+
vlan = object({
80+
ip = string
81+
})
7982
volumes = map(object({
8083
size = number
8184
}))

lib/bolt/config/default_regions.toml

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,71 @@ id = "54c60ee9-ae31-4a3f-b5ff-06aa5639310f"
66
provider = "linode"
77
provider_region = "us-southeast"
88
netnum = 0
9-
preferred_subnets = ["192.168.128.0/17"]
109
supports_vlan = true
1110

1211
[lnd-sfo]
1312
id = "19f1b737-0ff1-4676-a834-1af8c4e9890f"
1413
provider = "linode"
1514
provider_region = "us-west"
1615
netnum = 1
17-
preferred_subnets = ["192.168.128.0/17"]
1816

1917
[lnd-fra]
2018
id = "37aeb24a-12f6-45ea-ba7e-d2589588d7db"
2119
provider = "linode"
2220
provider_region = "eu-central"
2321
netnum = 2
24-
preferred_subnets = ["192.168.128.0/17"]
2522

2623
[lnd-syd]
2724
id = "6041893e-7a35-4ab7-a31d-9fd4d6f9dee2"
2825
provider = "linode"
2926
provider_region = "ap-southeast"
3027
netnum = 3
31-
preferred_subnets = ["192.168.128.0/17"]
3228

3329
[lnd-tok]
3430
id = "1f34955f-c0a5-472f-b1c6-1912698141eb"
3531
provider = "linode"
3632
provider_region = "ap-northeast"
3733
netnum = 4
38-
preferred_subnets = ["192.168.128.0/17"]
3934

4035
[lnd-mba]
4136
id = "a699aff0-9d2d-4cad-bef4-b929a78d430e"
4237
provider = "linode"
4338
provider_region = "ap-west"
4439
netnum = 5
45-
preferred_subnets = ["192.168.128.0/17"]
4640

4741
[lnd-tor]
4842
id = "33eaba37-0f06-4dc0-959a-2267481e63df"
4943
provider = "linode"
5044
provider_region = "ca-central"
5145
netnum = 6
52-
preferred_subnets = ["192.168.128.0/17"]
5346

5447
[lnd-dca]
5548
id = "732757b5-51dd-464f-a673-6ae40502c832"
5649
provider = "linode"
5750
provider_region = "us-iad"
5851
netnum = 7
59-
preferred_subnets = ["192.168.128.0/17"]
6052

6153
[lnd-dfw]
6254
id = "06e30e05-cd47-4cc7-adeb-8cb4a1a189b7"
6355
provider = "linode"
6456
provider_region = "us-central"
6557
netnum = 8
66-
preferred_subnets = ["192.168.128.0/17"]
6758

6859
[lnd-ewr]
6960
id = "ed6dac28-c16d-4c03-8daa-98adfbae4758"
7061
provider = "linode"
7162
provider_region = "us-east"
7263
netnum = 9
73-
preferred_subnets = ["192.168.128.0/17"]
7464

7565
[lnd-lon]
7666
id = "161e738d-f7ed-4d43-af64-7731e39835ef"
7767
provider = "linode"
7868
provider_region = "eu-west"
7969
netnum = 10
80-
preferred_subnets = ["192.168.128.0/17"]
8170

8271
[lnd-sgp]
8372
id = "4baddf3d-3a70-4139-aed7-21e06a74b9f4"
8473
provider = "linode"
8574
provider_region = "ap-south"
8675
netnum = 11
87-
preferred_subnets = ["192.168.128.0/17"]
76+

lib/bolt/config/src/ns.rs

-6
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ pub enum ClusterKind {
6666
#[serde(rename = "single_node")]
6767
SingleNode {
6868
public_ip: String,
69-
#[serde(default)]
70-
preferred_subnets: Vec<String>,
7169

7270
/// Restricts the resources of the core services so there are more resources availble for
7371
/// compiling code.
@@ -100,10 +98,6 @@ pub struct Region {
10098
pub provider: String,
10199
pub provider_region: String,
102100
pub netnum: usize,
103-
#[serde(default)]
104-
pub supports_vlan: bool,
105-
#[serde(default)]
106-
pub preferred_subnets: Vec<String>,
107101
}
108102

109103
#[derive(Serialize, Deserialize, Clone, Debug)]

lib/bolt/core/src/dep/terraform/gen.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,10 @@ async fn vars(ctx: &ProjectContext) {
147147
vars.insert("namespace".into(), json!(ns));
148148

149149
match &config.cluster.kind {
150-
ns::ClusterKind::SingleNode {
151-
public_ip,
152-
preferred_subnets,
153-
..
154-
} => {
150+
ns::ClusterKind::SingleNode { public_ip, .. } => {
155151
vars.insert("deploy_method_local".into(), json!(true));
156152
vars.insert("deploy_method_cluster".into(), json!(false));
157153
vars.insert("public_ip".into(), json!(public_ip));
158-
vars.insert("local_preferred_subnets".into(), json!(preferred_subnets));
159154
}
160155
ns::ClusterKind::Distributed {} => {
161156
vars.insert("deploy_method_local".into(), json!(false));
@@ -189,18 +184,6 @@ async fn vars(ctx: &ProjectContext) {
189184
vars.insert("domain_cdn".into(), json!(ctx.domain_cdn()));
190185
vars.insert("domain_job".into(), json!(ctx.domain_job()));
191186

192-
// Net
193-
vars.insert("svc_region_netmask".into(), json!(net::svc::REGION_NETMASK));
194-
vars.insert("svc_pool_netmask".into(), json!(net::svc::POOL_NETMASK));
195-
vars.insert("vpc_subnet".into(), json!(net::vpc::SUBNET));
196-
vars.insert("vpc_netmask".into(), json!(net::vpc::NETMASK));
197-
vars.insert("nebula_subnet".into(), json!(net::nebula::SUBNET));
198-
vars.insert("nebula_netmask".into(), json!(net::nebula::NETMASK));
199-
vars.insert("nebula_subnet_svc".into(), json!(net::nebula::SUBNET_SVC));
200-
vars.insert("nebula_netmask_svc".into(), json!(net::nebula::NETMASK_SVC));
201-
vars.insert("nebula_subnet_job".into(), json!(net::nebula::SUBNET_JOB));
202-
vars.insert("nebula_netmask_job".into(), json!(net::nebula::NETMASK_JOB));
203-
204187
// Cloudflare
205188
match &config.dns.provider {
206189
ns::DnsProvider::Cloudflare {

lib/bolt/core/src/dep/terraform/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod cli;
22
pub mod gen;
3-
pub mod nebula_firewall_rules;
43
pub mod net;
54
pub mod output;
65
pub mod pools;

0 commit comments

Comments
 (0)