feat(terraform): restructure control planes into a 3-node map with LAN etcd advertise and live machine CA — enables talos-cp-1/2/3 HA and drops worker configs
This commit is contained in:
+26
-66
@@ -14,38 +14,42 @@ locals {
|
||||
factory_image = "factory.talos.dev/installer/613e1592b2da41ae5e265e8789429f22e121aab91cb4deb6bc3c0b6262961245:${var.talos_version}"
|
||||
}
|
||||
|
||||
# Control plane machine configuration
|
||||
resource "local_file" "controlplane_config" {
|
||||
filename = "${path.module}/../cluster-config/controlplane.yaml"
|
||||
# Control plane machine configurations
|
||||
resource "local_file" "controlplane_configs" {
|
||||
for_each = var.controlplane_configs
|
||||
|
||||
filename = "${path.module}/../cluster-config/${each.key}.yaml"
|
||||
|
||||
content = templatefile("${path.module}/templates/controlplane.tftpl", {
|
||||
version = "v1alpha1"
|
||||
hostname = var.controlplane_config.hostname
|
||||
hostname = each.value.hostname
|
||||
token = var.machine_token
|
||||
ca_crt = var.machine_ca_crt
|
||||
ca_key = var.machine_ca_key
|
||||
lan_ip = var.controlplane_config.lan_ip
|
||||
lan_subnet = var.controlplane_config.lan_subnet
|
||||
lan_gateway = var.controlplane_config.lan_gateway
|
||||
wg0_ip = var.controlplane_config.wg0_ip
|
||||
wg0_subnet = var.controlplane_config.wg0_subnet
|
||||
wg0_port = var.controlplane_config.wg0_port
|
||||
wg0_private_key = var.controlplane_config.wg0_private_key
|
||||
wg0_peers = var.controlplane_config.wg0_peers
|
||||
wg1_ip = var.controlplane_config.wg1_ip
|
||||
wg1_subnet = var.controlplane_config.wg1_subnet
|
||||
wg1_port = var.controlplane_config.wg1_port
|
||||
wg1_private_key = var.controlplane_config.wg1_private_key
|
||||
wg1_peers = var.controlplane_config.wg1_peers
|
||||
lan_ip = each.value.lan_ip
|
||||
lan_subnet = each.value.lan_subnet
|
||||
lan_gateway = each.value.lan_gateway
|
||||
wg0_ip = each.value.wg0_ip
|
||||
wg0_subnet = each.value.wg0_subnet
|
||||
wg0_port = each.value.wg0_port
|
||||
wg0_private_key = each.value.wg0_private_key
|
||||
wg0_peers = each.value.wg0_peers
|
||||
wg1_ip = each.value.wg1_ip
|
||||
wg1_subnet = each.value.wg1_subnet
|
||||
wg1_port = each.value.wg1_port
|
||||
wg1_private_key = each.value.wg1_private_key
|
||||
wg1_peers = each.value.wg1_peers
|
||||
kubelet_image = local.kubelet_image
|
||||
cluster_dns_ip = local.cluster_dns_ip
|
||||
install_disk = var.controlplane_config.install_disk
|
||||
install_disk = each.value.install_disk
|
||||
factory_image = local.factory_image
|
||||
talos_version = var.talos_version
|
||||
longhorn_disks = var.controlplane_config.longhorn_disks
|
||||
longhorn_disks = each.value.longhorn_disks
|
||||
dns_servers = var.cluster_config.dns_servers
|
||||
forgejo_registry_ip = var.forgejo_registry_ip
|
||||
forgejo_hostname = var.forgejo_hostname
|
||||
zone = each.value.zone
|
||||
allow_scheduling = each.value.allow_scheduling
|
||||
|
||||
# Cluster config
|
||||
cluster_id = var.cluster_id
|
||||
@@ -75,54 +79,10 @@ resource "local_file" "controlplane_config" {
|
||||
})
|
||||
}
|
||||
|
||||
# Worker machine configurations
|
||||
resource "local_file" "worker_configs" {
|
||||
for_each = var.worker_configs
|
||||
|
||||
filename = "${path.module}/../cluster-config/${each.key}.yaml"
|
||||
|
||||
content = templatefile("${path.module}/templates/worker.tftpl", {
|
||||
version = "v1alpha1"
|
||||
hostname = each.value.hostname
|
||||
token = var.machine_token
|
||||
ca_crt = var.machine_ca_crt
|
||||
lan_ip = each.value.lan_ip
|
||||
lan_subnet = each.value.lan_subnet
|
||||
lan_gateway = each.value.lan_gateway
|
||||
kubelet_image = local.kubelet_image
|
||||
cluster_dns_ip = local.cluster_dns_ip
|
||||
install_disk = each.value.install_disk
|
||||
factory_image = local.factory_image
|
||||
talos_version = var.talos_version
|
||||
node_labels = each.value.node_labels
|
||||
|
||||
# Cluster config
|
||||
cluster_id = var.cluster_id
|
||||
cluster_secret = var.cluster_secret
|
||||
controlplane_ip = local.controlplane_ip
|
||||
cluster_name = var.cluster_name
|
||||
pod_subnets = var.cluster_config.pod_subnets
|
||||
service_subnets = var.cluster_config.service_subnets
|
||||
dns_domain = var.cluster_config.dns_domain
|
||||
bootstrap_token = var.bootstrap_token
|
||||
|
||||
# Kubernetes certs
|
||||
kubernetes_ca_crt = var.kubernetes_ca_crt
|
||||
|
||||
# Component images
|
||||
kube_proxy_img = local.kube_proxy_img
|
||||
})
|
||||
}
|
||||
|
||||
# Output paths for reference
|
||||
output "controlplane_config_path" {
|
||||
value = local_file.controlplane_config.filename
|
||||
description = "Path to generated controlplane config"
|
||||
}
|
||||
|
||||
output "worker_config_paths" {
|
||||
output "controlplane_config_paths" {
|
||||
value = {
|
||||
for k, v in local_file.worker_configs : k => v.filename
|
||||
for k, v in local_file.controlplane_configs : k => v.filename
|
||||
}
|
||||
description = "Paths to generated worker configs"
|
||||
description = "Paths to generated controlplane configs"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user