Refactor worker resources
This commit is contained in:
parent
be6e9b21ae
commit
f6bd6abd6e
51
IaC/nodes.tf
51
IaC/nodes.tf
|
@ -3,7 +3,7 @@
|
||||||
# Controller node resources
|
# Controller node resources
|
||||||
#
|
#
|
||||||
|
|
||||||
resource "openstack_networking_port_v2" "kubeport" {
|
resource "openstack_networking_port_v2" "kubecport" {
|
||||||
name = "${var.controller_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-port"
|
name = "${var.controller_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-port"
|
||||||
# We create as many ports as there are instances created
|
# We create as many ports as there are instances created
|
||||||
count = var.controller_instance_count
|
count = var.controller_instance_count
|
||||||
|
@ -46,7 +46,7 @@ resource "openstack_compute_instance_v2" "controller-nodes" {
|
||||||
group = openstack_compute_servergroup_v2.controllers.id
|
group = openstack_compute_servergroup_v2.controllers.id
|
||||||
}
|
}
|
||||||
network {
|
network {
|
||||||
port = resource.openstack_networking_port_v2.kubeport[count.index].id
|
port = resource.openstack_networking_port_v2.kubecport[count.index].id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,25 +54,56 @@ resource "openstack_compute_instance_v2" "controller-nodes" {
|
||||||
# Worker node resources
|
# Worker node resources
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Controller node resources
|
||||||
|
#
|
||||||
|
|
||||||
|
resource "openstack_networking_port_v2" "kubewport" {
|
||||||
|
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-port"
|
||||||
|
# We create as many ports as there are instances created
|
||||||
|
count = var.controller_instance_count
|
||||||
|
network_id = data.openstack_networking_network_v2.public.id
|
||||||
|
# A list of security group ID
|
||||||
|
security_group_ids = [
|
||||||
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
|
||||||
|
data.openstack_networking_secgroup_v2.allegress.id,
|
||||||
|
resource.openstack_networking_secgroup_v2.microk8s.id
|
||||||
|
]
|
||||||
|
admin_state_up = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_blockstorage_volume_v3" "kubewvolumeboot" {
|
||||||
|
count = var.controller_instance_count # size of cluster
|
||||||
|
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-vol"
|
||||||
|
description = "OS volume for kubernetes worker node ${count.index + 1}"
|
||||||
|
size = 100
|
||||||
|
image_id = data.openstack_images_image_v2.debian12image.id
|
||||||
|
enable_online_resize = true # Allow us to resize volume while attached.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "openstack_compute_instance_v2" "worker-nodes" {
|
resource "openstack_compute_instance_v2" "worker-nodes" {
|
||||||
count = var.worker_instance_count
|
count = var.worker_instance_count
|
||||||
name = "${var.worker_name}-${count.index}.${var.dns_suffix}"
|
name = "${var.worker_name}-${count.index}.${var.dns_suffix}"
|
||||||
flavor_name = "${var.worker_instance_type}"
|
flavor_name = "${var.worker_instance_type}"
|
||||||
key_pair = "${var.keyname}"
|
key_pair = "${var.keyname}"
|
||||||
security_groups = ["microk8s", "Allow SSH from SUNET jumphosts", "Allow ssh from the world"]
|
security_groups = [
|
||||||
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
|
||||||
|
data.openstack_networking_secgroup_v2.allegress.name,
|
||||||
|
resource.openstack_networking_secgroup_v2.microk8s.name
|
||||||
|
]
|
||||||
|
|
||||||
block_device {
|
block_device {
|
||||||
uuid = "5d24aca9-11be-4de1-9770-4a097d68f361"
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumeboot[count.index].id
|
||||||
source_type = "image"
|
source_type = "volume"
|
||||||
volume_size = 20
|
destination_type = "volume"
|
||||||
boot_index = 0
|
boot_index = 0
|
||||||
destination_type = "volume"
|
|
||||||
delete_on_termination = true
|
|
||||||
}
|
}
|
||||||
scheduler_hints {
|
scheduler_hints {
|
||||||
group = openstack_compute_servergroup_v2.workers.id
|
group = openstack_compute_servergroup_v2.workers.id
|
||||||
}
|
}
|
||||||
network {
|
network {
|
||||||
name = "public"
|
port = resource.openstack_networking_port_v2.kubewport[count.index].id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue