Extend worker node count and create rook volume on workers.

This commit is contained in:
Magnus Andersson 2024-10-15 14:52:52 +02:00
parent 71919802c8
commit da2d2004dd
Signed by: mandersson
GPG key ID: 1F7C896B34B28164
2 changed files with 18 additions and 8 deletions

View file

@ -56,15 +56,10 @@ resource "openstack_compute_instance_v2" "controller-nodes" {
# Worker node resources # Worker node resources
# #
#
# Controller node resources
#
resource "openstack_networking_port_v2" "kubewport" { resource "openstack_networking_port_v2" "kubewport" {
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-port" name = "${var.worker_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.worker_instance_count
network_id = data.openstack_networking_network_v2.public.id network_id = data.openstack_networking_network_v2.public.id
# A list of security group ID # A list of security group ID
security_group_ids = [ security_group_ids = [
@ -76,7 +71,7 @@ resource "openstack_networking_port_v2" "kubewport" {
} }
resource "openstack_blockstorage_volume_v3" "kubewvolumeboot" { resource "openstack_blockstorage_volume_v3" "kubewvolumeboot" {
count = var.controller_instance_count # size of cluster count = var.worker_instance_count # size of cluster
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-vol" name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-vol"
description = "OS volume for kubernetes worker node ${count.index + 1}" description = "OS volume for kubernetes worker node ${count.index + 1}"
size = 100 size = 100
@ -84,6 +79,14 @@ resource "openstack_blockstorage_volume_v3" "kubewvolumeboot" {
enable_online_resize = true # Allow us to resize volume while attached. enable_online_resize = true # Allow us to resize volume while attached.
} }
resource "openstack_blockstorage_volume_v3" "kubewvolumerook" {
count = var.worker_instance_count # size of cluster
name = "${var.worker_name}${count.index+1}-${replace(var.dns_suffix,".","-")}-rook-vol"
description = "Rook storage volume for kubernetes worker node ${count.index + 1}"
size = 100
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
@ -102,6 +105,13 @@ resource "openstack_compute_instance_v2" "worker-nodes" {
destination_type = "volume" destination_type = "volume"
boot_index = 0 boot_index = 0
} }
block_device {
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumerook[count.index].id
source_type = "volume"
destination_type = "volume"
boot_index = 1
}
scheduler_hints { scheduler_hints {
group = openstack_compute_servergroup_v2.workers.id group = openstack_compute_servergroup_v2.workers.id
} }

View file

@ -9,7 +9,7 @@ variable "keyname" {
} }
variable "worker_instance_count" { variable "worker_instance_count" {
default = "3" default = "4"
} }
variable "controller_instance_count" { variable "controller_instance_count" {
default = "3" default = "3"