2024-10-21 13:09:34 +00:00
|
|
|
#
|
2024-10-22 14:24:49 +00:00
|
|
|
# Global DCO definitions
|
2024-10-21 13:09:34 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
locals {
|
|
|
|
dcodc = "dco"
|
|
|
|
dconodenrbase = index(var.datacenters, "dco")
|
|
|
|
dcoindexjump = length(var.datacenters)
|
|
|
|
}
|
|
|
|
|
2024-10-22 14:24:49 +00:00
|
|
|
#
|
|
|
|
# Control node resources DCO
|
|
|
|
#
|
|
|
|
|
|
|
|
resource "openstack_networking_port_v2" "kubecport-dco" {
|
2024-10-23 08:07:08 +00:00
|
|
|
name = "${var.controller_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dcodc}-port"
|
2024-10-22 14:24:49 +00:00
|
|
|
# We create as many ports as there are instances created
|
|
|
|
count = var.controllerdcreplicas
|
|
|
|
network_id = data.openstack_networking_network_v2.public-dco.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-dco.id,
|
2024-10-30 14:17:58 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-dco.id,
|
|
|
|
resource.openstack_networking_secgroup_v2.k8s-external-control-dco.id
|
2024-10-22 14:24:49 +00:00
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
provider = openstack.dco
|
|
|
|
}
|
|
|
|
|
|
|
|
# Boot volume for node
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubecvolumeboot-dco" {
|
2024-10-23 08:07:08 +00:00
|
|
|
count = var.controllerdcreplicas # Replicas per datacenter
|
|
|
|
name = "${var.controller_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dcodc}-vol"
|
|
|
|
description = "OS volume for kubernetes worker node ${count.index * local.dcoindexjump + 1 + local.dconodenrbase}"
|
2024-10-22 14:24:49 +00:00
|
|
|
size = 100
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image-dco.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
provider = openstack.dco
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_compute_instance_v2" "controller-nodes-dco" {
|
|
|
|
count = var.controllerdcreplicas # Replicas per datacenter
|
2024-10-23 08:07:08 +00:00
|
|
|
name = "${var.controller_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}.${var.dns_suffix}"
|
2024-10-22 14:24:49 +00:00
|
|
|
flavor_name = "${var.controller_instance_type}"
|
|
|
|
key_pair = "${var.keynameworkers}"
|
|
|
|
provider = openstack.dco
|
|
|
|
security_groups = [
|
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-dco.name,
|
2024-10-30 14:17:58 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-dco.name,
|
|
|
|
resource.openstack_networking_secgroup_v2.k8s-external-control-dco.name
|
2024-10-22 14:24:49 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubecvolumeboot-dco[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
scheduler_hints {
|
|
|
|
group = openstack_compute_servergroup_v2.controllers-dco.id
|
|
|
|
}
|
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.kubecport-dco[count.index].id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Worker node resources DCO
|
|
|
|
#
|
|
|
|
|
2024-10-21 13:09:34 +00:00
|
|
|
resource "openstack_networking_port_v2" "kubewport-dco" {
|
|
|
|
name = "${var.worker_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dcodc}-port"
|
|
|
|
# We create as many ports as there are instances created
|
|
|
|
count = var.workerdcreplicas
|
|
|
|
network_id = data.openstack_networking_network_v2.public-dco.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-dco.id,
|
2024-10-30 22:56:25 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-dco.id,
|
|
|
|
resource.openstack_networking_secgroup_v2.k8s-external-worker-dco.id
|
2024-10-21 13:09:34 +00:00
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
provider = openstack.dco
|
|
|
|
}
|
|
|
|
|
|
|
|
# Boot volume for node
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubewvolumeboot-dco" {
|
|
|
|
count = var.workerdcreplicas # Replicas per datacenter
|
2024-10-23 08:07:08 +00:00
|
|
|
name = "${var.worker_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dcodc}-vol"
|
2024-10-21 13:09:34 +00:00
|
|
|
description = "OS volume for kubernetes worker node ${count.index * local.dcoindexjump + 1 + local.dconodenrbase}"
|
|
|
|
size = 100
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image-dco.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
provider = openstack.dco
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubewvolumerook-dco" {
|
|
|
|
count = var.workerdcreplicas # Replicas per datacenter
|
2024-10-23 08:07:08 +00:00
|
|
|
name = "${var.worker_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dcodc}-rook-vol"
|
2024-10-21 13:09:34 +00:00
|
|
|
description = "Rook storage volume for kubernetes worker node ${count.index * local.dcoindexjump + 1 + local.dconodenrbase}"
|
|
|
|
size = 100
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
provider = openstack.dco
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_compute_instance_v2" "worker-nodes-dco" {
|
|
|
|
count = var.workerdcreplicas # Replicas per datacenter
|
|
|
|
name = "${var.worker_name}${count.index * local.dcoindexjump + 1 + local.dconodenrbase}.${var.dns_suffix}"
|
|
|
|
flavor_name = "${var.worker_instance_type}"
|
|
|
|
key_pair = "${var.keynameworkers}"
|
|
|
|
provider = openstack.dco
|
|
|
|
security_groups = [
|
2024-10-23 08:07:08 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.microk8s-dco.name,
|
2024-10-30 22:56:25 +00:00
|
|
|
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-dco.name,
|
|
|
|
resource.openstack_networking_secgroup_v2.k8s-external-worker-dco.name
|
2024-10-21 13:09:34 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumeboot-dco[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
|
|
|
}
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumerook-dco[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
scheduler_hints {
|
|
|
|
group = openstack_compute_servergroup_v2.workers-dco.id
|
|
|
|
}
|
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.kubewport-dco[count.index].id
|
|
|
|
}
|
|
|
|
}
|