Skip to content

Commit

Permalink
Support the addition of a data disk to the worker nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
khanh-ph committed Aug 10, 2023
1 parent 5b78a09 commit 7881135
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 17 deletions.
12 changes: 12 additions & 0 deletions modules/proxmox_ubuntu_vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ resource "proxmox_vm_qemu" "ubuntu_vm" {
iothread = 1
}

dynamic "disk" {
for_each = var.add_worker_node_data_disk ? [var.worker_node_data_disk_size] : []

content {
slot = 1
type = "virtio"
storage = var.worker_node_data_disk_storage
size = "${var.worker_node_data_disk_size}G"
iothread = 1
}
}

network {
model = "virtio"
bridge = var.vm_net_name
Expand Down
18 changes: 18 additions & 0 deletions modules/proxmox_ubuntu_vm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ variable "vm_host_number" {
description = "The host number of the VM in the subnet"
}

variable "add_worker_node_data_disk" {
type = bool
description = "A boolean value that indicates whether to add a data disk to each worker node of the cluster."
default = false
}

variable "worker_node_data_disk_storage" {
type = string
description = "The storage pool where the data disk is placed."
default = ""
}

variable "worker_node_data_disk_size" {
type = string
description = "The size of worker node data disk in Gigabyte."
default = 10
}

#
# Local vars
#
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ variable "vm_os_disk_storage" {
description = "Default storage pool where OS VM disk is placed."
}

variable "add_worker_node_data_disk" {
type = bool
description = "A boolean value that indicates whether to add a data disk to each worker node of the cluster."
default = false
}

variable "worker_node_data_disk_storage" {
type = string
description = "The storage pool where the data disk is placed."
default = ""
}

variable "worker_node_data_disk_size" {
type = string
description = "The size of worker node data disk in Gigabyte."
default = 10
}

variable "vm_ubuntu_tmpl_name" {
type = string
description = "Name of Cloud-init template Ubuntu VM."
Expand Down
37 changes: 20 additions & 17 deletions vm-k8s-nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@ module "k8s_control_plane_nodes" {
module "k8s_worker_nodes" {
source = "./modules/proxmox_ubuntu_vm"

node_count = var.vm_k8s_worker["node_count"]
pm_host = var.pm_host
vm_ubuntu_tmpl_name = var.vm_ubuntu_tmpl_name
vm_name_prefix = "${var.env_name}-k8s-worker"
vm_max_vcpus = var.vm_max_vcpus
vm_vcpus = var.vm_k8s_worker["vcpus"]
vm_sockets = var.vm_sockets
vm_cpu_type = var.vm_cpu_type
vm_memory_mb = var.vm_k8s_worker["memory"]
vm_os_disk_storage = var.vm_os_disk_storage
vm_os_disk_size_gb = var.vm_k8s_worker["disk_size"]
vm_net_name = var.internal_net_name
vm_net_subnet_cidr = var.internal_net_subnet_cidr
vm_host_number = 20
vm_user = var.vm_user
vm_tags = "${var.env_name};terraform;k8s-worker"
ssh_public_keys = var.ssh_public_keys
node_count = var.vm_k8s_worker["node_count"]
pm_host = var.pm_host
vm_ubuntu_tmpl_name = var.vm_ubuntu_tmpl_name
vm_name_prefix = "${var.env_name}-k8s-worker"
vm_max_vcpus = var.vm_max_vcpus
vm_vcpus = var.vm_k8s_worker["vcpus"]
vm_sockets = var.vm_sockets
vm_cpu_type = var.vm_cpu_type
vm_memory_mb = var.vm_k8s_worker["memory"]
vm_os_disk_storage = var.vm_os_disk_storage
vm_os_disk_size_gb = var.vm_k8s_worker["disk_size"]
vm_net_name = var.internal_net_name
vm_net_subnet_cidr = var.internal_net_subnet_cidr
vm_host_number = 20
vm_user = var.vm_user
vm_tags = "${var.env_name};terraform;k8s-worker"
ssh_public_keys = var.ssh_public_keys
add_worker_node_data_disk = var.add_worker_node_data_disk
worker_node_data_disk_storage = var.worker_node_data_disk_storage
worker_node_data_disk_size = var.worker_node_data_disk_size
}

output "k8s_control_plane" {
Expand Down

0 comments on commit 7881135

Please sign in to comment.