mirror of
https://github.com/puppetmaster/typhoon.git
synced 2024-12-26 19:59:34 +01:00
48d4973957
* Define a dual-stack virtual network with both IPv4 and IPv6 private address space. Change `host_cidr` variable (string) to a `network_cidr` variable (object) with "ipv4" and "ipv6" fields that list CIDR strings. * Define dual-stack controller and worker subnets. Disable Azure default outbound access (a deprecated fallback mechanism) * Enable dual-stack load balancing to Kubernetes Ingress by adding a public IPv6 frontend IP and LB rule to the load balancer. * Enable worker outbound IPv6 connectivity through load balancer SNAT by adding an IPv6 frontend IP and outbound rule * Configure controller nodes with a public IPv6 address to provide direct outbound IPv6 connectivity * Add an IPv6 worker backend pool. Azure requires separate IPv4 and IPv6 backend pools, though the health probe can be shared * Extend network security group rules for IPv6 source/destinations Checklist: Access to controller and worker nodes via IPv6 addresses: * SSH access to controller nodes via public IPv6 address * SSH access to worker nodes via (private) IPv6 address (via controller) Outbound IPv6 connectivity from controller and worker nodes: ``` nc -6 -zv ipv6.google.com 80 Ncat: Version 7.94 ( https://nmap.org/ncat ) Ncat: Connected to [2607:f8b0:4001:c16::66]:80. Ncat: 0 bytes sent, 0 bytes received in 0.02 seconds. ``` Serve Ingress traffic via IPv4 or IPv6 just requires setting up A and AAAA records and running the ingress controller with `hostNetwork: true` since, hostPort only forwards IPv4 traffic
70 lines
2.3 KiB
HCL
70 lines
2.3 KiB
HCL
locals {
|
|
# Subdivide the virtual network into subnets
|
|
# - controllers use netnum 0
|
|
# - workers use netnum 1
|
|
controller_subnets = {
|
|
ipv4 = [for i, cidr in var.network_cidr.ipv4 : cidrsubnet(cidr, 1, 0)]
|
|
ipv6 = [for i, cidr in var.network_cidr.ipv6 : cidrsubnet(cidr, 16, 0)]
|
|
}
|
|
worker_subnets = {
|
|
ipv4 = [for i, cidr in var.network_cidr.ipv4 : cidrsubnet(cidr, 1, 1)]
|
|
ipv6 = [for i, cidr in var.network_cidr.ipv6 : cidrsubnet(cidr, 16, 1)]
|
|
}
|
|
cluster_subnets = {
|
|
ipv4 = concat(local.controller_subnets.ipv4, local.worker_subnets.ipv4)
|
|
ipv6 = concat(local.controller_subnets.ipv6, local.worker_subnets.ipv6)
|
|
}
|
|
}
|
|
|
|
# Organize cluster into a resource group
|
|
resource "azurerm_resource_group" "cluster" {
|
|
name = var.cluster_name
|
|
location = var.region
|
|
}
|
|
|
|
resource "azurerm_virtual_network" "network" {
|
|
name = var.cluster_name
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
|
location = azurerm_resource_group.cluster.location
|
|
address_space = concat(
|
|
var.network_cidr.ipv4,
|
|
var.network_cidr.ipv6
|
|
)
|
|
}
|
|
|
|
# Subnets - separate subnets for controllers and workers because Azure
|
|
# network security groups are oriented around address prefixes rather
|
|
# than instance tags (GCP) or security group membership (AWS)
|
|
|
|
resource "azurerm_subnet" "controller" {
|
|
name = "controller"
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
|
virtual_network_name = azurerm_virtual_network.network.name
|
|
address_prefixes = concat(
|
|
local.controller_subnets.ipv4,
|
|
local.controller_subnets.ipv6,
|
|
)
|
|
default_outbound_access_enabled = false
|
|
}
|
|
|
|
resource "azurerm_subnet_network_security_group_association" "controller" {
|
|
subnet_id = azurerm_subnet.controller.id
|
|
network_security_group_id = azurerm_network_security_group.controller.id
|
|
}
|
|
|
|
resource "azurerm_subnet" "worker" {
|
|
name = "worker"
|
|
resource_group_name = azurerm_resource_group.cluster.name
|
|
virtual_network_name = azurerm_virtual_network.network.name
|
|
address_prefixes = concat(
|
|
local.worker_subnets.ipv4,
|
|
local.worker_subnets.ipv6,
|
|
)
|
|
default_outbound_access_enabled = false
|
|
}
|
|
|
|
resource "azurerm_subnet_network_security_group_association" "worker" {
|
|
subnet_id = azurerm_subnet.worker.id
|
|
network_security_group_id = azurerm_network_security_group.worker.id
|
|
}
|