Skip to content

Commit

Permalink
Merge pull request #23 from christensenjairus/fix_gateway_for_ipv6
Browse files Browse the repository at this point in the history
Fix gateway for IPv6 following model that @NicoMirland suggested
  • Loading branch information
christensenjairus authored Jan 15, 2025
2 parents ed3cd3b + 1b6135c commit 53b0183
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions terraform/clusters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ variable "clusters" {
vlan_id : optional(number, null) # Optional. The vlan id to assign to the network interfaces of the VMs. Defaults to <cluster_id>00 (e.e. 100, 200, 300, etc.)
vlan_name : optional(string, null) # Optional. The name of the VLAN in Unifi. Defaults to the cluster name in all caps.
ipv4 : object({
subnet_prefix : string # Required. First three octets of the host IPv4 network's subnet (assuming its a /24)
subnet_prefix : optional(string, "10.0.0") # Optional. First three octets of the host IPv4 network's subnet (assuming its a /24)
gateway : optional(string, "10.0.0.1") # Optional. Gateway for vm hosts
pod_cidr : optional(string, "10.42.0.0/16") # Optional. Cidr range for pod networking internal to cluster. Shouldn't overlap with ipv4 lan network. These must differ cluster to cluster if using clustermesh.
svc_cidr : optional(string, "10.43.0.0/16") # Optional. Cidr range for service networking internal to cluster. Shouldn't overlap with ipv4 lan network.
dns1 : optional(string, "1.1.1.1") # Optional. Primary dns server for vm hosts
dns2 : optional(string, "1.0.0.1") # Optional. Secondary dns server for vm hosts
gateway : string # Required. Gateway for vm hosts
management_cidrs : optional(string, "") # Optional. Proxmox list of ipv4 IPs or cidrs that you want to be able to reach the K8s api and ssh into the hosts. Only used if use_pve_firewall is true.
lb_cidrs : optional(string, "") # Optional. IPv4 cidrs to use for MetalLB.
})
ipv6 : object({
enabled : optional(bool, false) # Optional. Whether or not to enable IPv6 networking for the VMs and network in the cluster.
dual_stack : optional(bool, false) # Optional. Whether or not to enable dual stack networking for the cluster. EXPECT COMPLICATIONS IF CHANGED AFTER INITIAL SETUP.
subnet_prefix : optional(string, "2001:db8:cafe:0000") # Optional. The first four hex sections of the host IPv6 network's subnet (assuming its a /64). Used for a static network configuration.
gateway : optional(string, "2001:db8:cafe:0000::1") # Optional. Gateway for vm hosts
pod_cidr : optional(string, "2001:db8:cafe:0000:244::/80") # Optional. Cidr range for pod networking internal to cluster. Should be a subsection of the ipv6 lan network. These must differ cluster to cluster if using clustermesh.
svc_cidr : optional(string, "2001:db8:cafe:0000:96::/112") # Optional. Cidr range for service networking internal to cluster. Should be a subsection of the ipv6 lan network.
dns1 : optional(string, "2607:fa18::1") # Optional. Primary dns server for vm hosts
Expand Down Expand Up @@ -87,9 +88,9 @@ variable "clusters" {
networking = {
ipv4 = {
subnet_prefix = "10.0.1"
gateway = "10.0.1.1"
management_cidrs = "10.0.0.0/30,10.0.60.2,10.0.50.5,10.0.50.6"
lb_cidrs = "10.0.1.200/29,10.0.1.208/28,10.0.1.224/28,10.0.1.240/29,10.0.1.248/30,10.0.1.252/31"
gateway = "10.0.1.1"
}
ipv6 = {}
kube_vip = {
Expand Down Expand Up @@ -123,9 +124,9 @@ variable "clusters" {
networking = {
ipv4 = {
subnet_prefix = "10.0.2"
gateway = "10.0.2.1"
management_cidrs = "10.0.0.0/30,10.0.60.2,10.0.50.5,10.0.50.6"
lb_cidrs = "10.0.2.200/29,10.0.2.208/28,10.0.2.224/28,10.0.2.240/29,10.0.2.248/30,10.0.2.252/31"
gateway = "10.0.2.1"
}
ipv6 = {}
kube_vip = {
Expand Down Expand Up @@ -171,9 +172,9 @@ variable "clusters" {
networking = {
ipv4 = {
subnet_prefix = "10.0.3"
gateway = "10.0.3.1"
management_cidrs = "10.0.0.0/30,10.0.60.2,10.0.50.5,10.0.50.6"
lb_cidrs = "10.0.3.200/29,10.0.3.208/28,10.0.3.224/28,10.0.3.240/29,10.0.3.248/30,10.0.3.252/31"
gateway = "10.0.3.1"
}
ipv6 = {}
kube_vip = {
Expand Down
4 changes: 2 additions & 2 deletions terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ locals {
vlan_id = cluster.networking.vlan_id == null ? "${cluster.cluster_id}00" : cluster.networking.vlan_id
ipv4 : {
vm_ip = "${cluster.networking.ipv4.subnet_prefix}.${specs.start_ip + i}"
gateway = "${cluster.networking.ipv4.gateway}"
gateway = cluster.networking.ipv4.gateway
dns1 = cluster.networking.ipv4.dns1
dns2 = cluster.networking.ipv4.dns2
lb_cidrs = cluster.networking.ipv4.lb_cidrs
Expand All @@ -32,7 +32,7 @@ locals {
enabled = cluster.networking.ipv6.enabled
dual_stack = cluster.networking.ipv6.enabled ? cluster.networking.ipv6.dual_stack: false
vm_ip = cluster.networking.ipv6.enabled ? "${cluster.networking.ipv6.subnet_prefix}::${specs.start_ip + i}" : null
gateway = cluster.networking.ipv6.enabled ? "${cluster.networking.ipv6.subnet_prefix}::1" : null
gateway = cluster.networking.ipv6.enabled ? cluster.networking.ipv6.gateway : null
dns1 = cluster.networking.ipv6.enabled ? cluster.networking.ipv6.dns1: null
dns2 = cluster.networking.ipv6.enabled ? cluster.networking.ipv6.dns2: null
lb_cidrs = cluster.networking.ipv6.enabled ? cluster.networking.ipv6.lb_cidrs : null
Expand Down

1 comment on commit 53b0183

@NicoMirland
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello ! Yes I totally agree with this commit.
With this, one can specify several clusters placed on same subnet easily. That's my case ^^

Please sign in to comment.