moving project to gitea
This commit is contained in:
98
terraform/compute.tf
Normal file
98
terraform/compute.tf
Normal file
@@ -0,0 +1,98 @@
|
||||
locals {
|
||||
image_name = "talos-1.10.2"
|
||||
flavor_name = "medium"
|
||||
net_id = openstack_networking_network_v2.net.id
|
||||
secgroup_id = openstack_networking_secgroup_v2.secgroup.id # Using existing security group ID
|
||||
|
||||
cp_fixed_ips = ["10.0.0.10", "10.0.0.11", "10.0.0.12"]
|
||||
worker_fixed_ips = ["10.0.0.20", "10.0.0.21", "10.0.0.22"]
|
||||
}
|
||||
|
||||
# 3 control-planes
|
||||
resource "openstack_compute_instance_v2" "cp" {
|
||||
count = 3
|
||||
name = "ikt210-g04-control-plane-${count.index}"
|
||||
image_name = local.image_name
|
||||
flavor_name = local.flavor_name
|
||||
security_groups = [local.secgroup_id]
|
||||
|
||||
user_data = yamlencode(merge(
|
||||
yamldecode(file("./../talos/worker.yaml")),
|
||||
{
|
||||
cluster = merge(
|
||||
yamldecode(file("./../talos/controlplane.yaml")).cluster,
|
||||
{
|
||||
controlPlane = {
|
||||
endpoint = "https://${openstack_networking_floatingip_v2.talos_ikt210_g04_floatingip[0].address}:6443"
|
||||
}
|
||||
}
|
||||
)
|
||||
machine = merge(
|
||||
yamldecode(file("./../talos/controlplane.yaml")).machine,
|
||||
{
|
||||
certSANs = [
|
||||
openstack_networking_floatingip_v2.talos_ikt210_g04_floatingip[count.index].address,
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
))
|
||||
|
||||
network {
|
||||
uuid = local.net_id
|
||||
fixed_ip_v4 = local.cp_fixed_ips[count.index]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# 3 workers
|
||||
resource "openstack_compute_instance_v2" "worker" {
|
||||
count = 3
|
||||
name = "ikt210-g04-worker-${count.index}"
|
||||
image_name = local.image_name
|
||||
flavor_name = local.flavor_name
|
||||
security_groups = [local.secgroup_id]
|
||||
|
||||
user_data = yamlencode(merge(
|
||||
yamldecode(file("./../talos/worker.yaml")),
|
||||
{
|
||||
cluster = merge(
|
||||
yamldecode(file("./../talos/worker.yaml")).cluster,
|
||||
{
|
||||
controlPlane = {
|
||||
endpoint = "https://${openstack_networking_floatingip_v2.talos_ikt210_g04_floatingip[0].address}:6443"
|
||||
}
|
||||
}
|
||||
)
|
||||
machine = merge(
|
||||
yamldecode(file("./../talos/worker.yaml")).machine,
|
||||
{
|
||||
certSANs = [
|
||||
openstack_networking_floatingip_v2.talos_ikt210_g04_floatingip[count.index].address,
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
))
|
||||
|
||||
network {
|
||||
uuid = local.net_id
|
||||
fixed_ip_v4 = local.worker_fixed_ips[count.index]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Reserve 3 floating IPs for the control-planes
|
||||
resource "openstack_networking_floatingip_v2" "talos_ikt210_g04_floatingip" {
|
||||
count = 3
|
||||
pool = "provider"
|
||||
# Openstack will automatically assign available IPs
|
||||
}
|
||||
|
||||
# Associate each FIP with the corresponding control-plane
|
||||
resource "openstack_compute_floatingip_associate_v2" "cp_assoc" {
|
||||
count = 3
|
||||
floating_ip = openstack_networking_floatingip_v2.talos_ikt210_g04_floatingip[count.index].address
|
||||
instance_id = openstack_compute_instance_v2.cp[count.index].id
|
||||
fixed_ip = openstack_compute_instance_v2.cp[count.index].network[0].fixed_ip_v4
|
||||
}
|
||||
Reference in New Issue
Block a user