mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
🛜 Generate HAProxy configuration for Proxmox IPv6 scenario
This commit is contained in:
37
prepare-labs/terraform/virtual-machines/proxmox/haproxy.tf
Normal file
37
prepare-labs/terraform/virtual-machines/proxmox/haproxy.tf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# If we deploy in IPv6-only environments, and the students don't have IPv6
|
||||||
|
# connectivity, we want to offer a way to connect anyway. Our solution is
|
||||||
|
# to generate an HAProxy configuration snippet, that can be copied to a
|
||||||
|
# DualStack machine which will act as a proxy to our IPv6 machines.
|
||||||
|
# Note that the snippet still has to be copied, so this is not a 100%
|
||||||
|
# streamlined solution!
|
||||||
|
|
||||||
|
locals {
|
||||||
|
portmaps = {
|
||||||
|
for key, value in local.nodes :
|
||||||
|
(10000 + proxmox_virtual_environment_vm._[key].vm_id) => local.ip_addresses[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "local_file" "haproxy" {
|
||||||
|
filename = "./${var.tag}.cfg"
|
||||||
|
file_permission = "0644"
|
||||||
|
content = join("\n", [for port, address in local.portmaps : <<-EOT
|
||||||
|
frontend f${port}
|
||||||
|
bind *:${port}
|
||||||
|
default_backend b${port}
|
||||||
|
backend b${port}
|
||||||
|
mode tcp
|
||||||
|
server s${port} [${address}]:22 maxconn 16
|
||||||
|
EOT
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "local_file" "sshproxy" {
|
||||||
|
filename = "sshproxy.txt"
|
||||||
|
file_permission = "0644"
|
||||||
|
content = join("", [
|
||||||
|
for cid in range(1, 1 + var.how_many_clusters) :
|
||||||
|
format("ssh -l k8s -p %d\n", proxmox_virtual_environment_vm._[format("c%03dn%03d", cid, 1)].vm_id + 10000)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
@@ -111,4 +111,3 @@ locals {
|
|||||||
addr if addr != "127.0.0.1" && addr != "::1"][0]
|
addr if addr != "127.0.0.1" && addr != "::1"][0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ proxmox_password = "CHANGEME"
|
|||||||
|
|
||||||
# Which storage to use for VM disks. Defaults to "local".
|
# Which storage to use for VM disks. Defaults to "local".
|
||||||
#proxmox_storage = "ceph"
|
#proxmox_storage = "ceph"
|
||||||
|
#proxmox_storage = "local-zfs"
|
||||||
|
|
||||||
proxmox_template_node_name = "CHANGEME"
|
# We recently rewrote the Proxmox configurations to automatically
|
||||||
proxmox_template_vm_id = CHANGEME
|
# detect which template to use; so these variables aren't used anymore.
|
||||||
|
#proxmox_template_node_name = "CHANGEME"
|
||||||
|
#proxmox_template_vm_id = CHANGEME
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user