Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
*.tfplan
cloud.tf
tmp
*.tfvars

# Exclude example.tfvars from being ignored
!example.tfvars
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to exclude all .tfvars files from being checked, just in case


# OS files
Icon*
.DS_Store
.env*
.env*

61 changes: 31 additions & 30 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 59 additions & 61 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ vm_k8s_worker = {

# Kubernetes settings
########################################################################
kube_version = "v1.24.6"
kube_version = "v1.29.5"
kube_network_plugin = "calico"
enable_nodelocaldns = false
podsecuritypolicy_enabled = false
persistent_volumes_enabled = false
helm_enabled = false
ingress_nginx_enabled = false
argocd_enabled = false
argocd_version = "v2.4.12"
argocd_version = "v2.11.4"
46 changes: 28 additions & 18 deletions modules/proxmox_ubuntu_vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.14"
version = "3.0.1-rc3"
}
}
}
Expand All @@ -27,27 +27,37 @@ resource "proxmox_vm_qemu" "ubuntu_vm" {
scsihw = "virtio-scsi-single"
hotplug = "network,disk,usb,memory,cpu"
numa = true
automatic_reboot = false
automatic_reboot = true
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there were a problems with modify operations without this property set to true

desc = "This VM is managed by Terraform, cloned from an Cloud-init Ubuntu image, configured with an internal network and supports CPU hotplug/hot unplug and memory hotplug capabilities."
tags = var.vm_tags

disk {
slot = 0
type = "virtio"
storage = var.vm_os_disk_storage
size = "${var.vm_os_disk_size_gb}G"
iothread = 1
}

dynamic "disk" {
for_each = var.add_worker_node_data_disk ? [var.worker_node_data_disk_size] : []
disks {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new disks structure in updated provider

virtio {
virtio0 {
disk {
size = "${var.vm_os_disk_size_gb}G"
storage = var.vm_os_disk_storage
iothread = true
}
}

content {
slot = 1
type = "virtio"
storage = var.worker_node_data_disk_storage
size = "${var.worker_node_data_disk_size}G"
iothread = 1
dynamic "virtio1" {
for_each = var.add_worker_node_data_disk ? [var.worker_node_data_disk_size] : []
content {
disk {
size = "${var.worker_node_data_disk_size}G"
storage = var.worker_node_data_disk_storage
iothread = true
}
}
}
}
ide {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous config missed cloudinit drive, therefore VMs were not initialized properly

ide0 {
cloudinit {
storage = var.vm_os_disk_storage
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/proxmox_ubuntu_vm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ variable "vm_os_disk_storage" {
variable "vm_ubuntu_tmpl_name" {
type = string
description = "Name of Cloud-init template Ubuntu VM."
default = "ubuntu-2204"
default = "ubuntu-2404"
}

variable "vm_host_number" {
Expand Down
4 changes: 2 additions & 2 deletions providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.14"
version = "3.0.1-rc3"
}
null = {
source = "hashicorp/null"
version = "3.2.1"
version = "3.2.2"
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions scripts/setup_kubespray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ if ! command -v docker &> /dev/null; then
exit 1
fi

# Check and add DPkg::Lock::Timeout=600 to apt-get install if not already present
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added simple script adding lock timeout, otherwise script would fail sometimes

if ! grep -q 'apt-get install.*DPkg::Lock::Timeout=600' get-docker.sh; then
sed -i 's/apt-get install/apt-get install -o DPkg::Lock::Timeout=600/g' get-docker.sh
fi

# Check and add DPkg::Lock::Timeout=600 to apt-get update if not already present
if ! grep -q 'apt-get update.*DPkg::Lock::Timeout=600' get-docker.sh; then
sed -i 's/apt-get update/apt-get update -o DPkg::Lock::Timeout=600/g' get-docker.sh
fi

# Install Docker
if ! sudo sh get-docker.sh; then
echo "Error installing Docker. Exiting." >&2
Expand Down
10 changes: 6 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ variable "internal_net_subnet_cidr" {
variable "ssh_private_key" {
type = string
description = "SSH private key in base64, will be used by Terraform client to connect to the VM after provisioning"
sensitive = false
}

variable "ssh_public_keys" {
type = string
description = "SSH public keys in base64"
sensitive = false
}

variable "vm_user" {
Expand Down Expand Up @@ -145,7 +147,7 @@ variable "worker_node_data_disk_size" {
variable "vm_ubuntu_tmpl_name" {
type = string
description = "Name of Cloud-init template Ubuntu VM"
default = "ubuntu-2204"
default = "ubuntu-2404"
}

variable "bastion_ssh_ip" {
Expand Down Expand Up @@ -191,13 +193,13 @@ variable "create_kubespray_host" {
variable "kubespray_image" {
type = string
description = "The Docker image to deploy Kubespray"
default = "khanhphhub/kubespray:v2.22.0"
default = "quay.io/kubespray/kubespray:v2.25.0"
}

variable "kube_version" {
type = string
description = "Kubernetes version"
default = "v1.24.6"
default = "v1.29.5"
}
variable "kube_network_plugin" {
type = string
Expand Down Expand Up @@ -238,7 +240,7 @@ variable "argocd_enabled" {
variable "argocd_version" {
type = string
description = "The ArgoCD version to be installed"
default = "v2.4.12"
default = "v2.11.4"
}


4 changes: 2 additions & 2 deletions vm-k8s-nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module "k8s_control_plane_nodes" {
vm_net_subnet_cidr = var.internal_net_subnet_cidr
vm_host_number = 10
vm_user = var.vm_user
vm_tags = "${var.env_name};terraform;k8s-control-plane"
vm_tags = "${var.env_name};terraform;k8s_control_plane"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new naming convention, - is forbidden

ssh_public_keys = var.ssh_public_keys
use_legacy_naming_convention = var.use_legacy_naming_convention
}
Expand All @@ -39,7 +39,7 @@ module "k8s_worker_nodes" {
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"
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
Expand Down
2 changes: 1 addition & 1 deletion vm-kubespray-host.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ resource "null_resource" "setup_kubespray" {
provisioner "remote-exec" {
inline = [
local.setup_kubespray_script_content,
"echo ${var.ssh_private_key} | base64 -d > ${local.kubespray_data_dir}/id_rsa",
"echo \"${var.ssh_private_key}\" | base64 -d > ${local.kubespray_data_dir}/id_rsa",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added missing "key" quotes, fails without it

<<-EOT
cat <<EOF > ${local.kubespray_data_dir}/inventory.ini
${local.kubespray_inventory_content}
Expand Down