feat: Manage VM identifiers

This commit is contained in:
Peter 2025-10-31 17:24:40 +01:00
parent 66c61fafc9
commit 24b89de734
Signed by: Peter
SSH key fingerprint: SHA256:B5tYaxBExaDm74r1px9iVeZ6F/ZDiyiy9SbBqfZYrvg
7 changed files with 8 additions and 29 deletions

View file

@ -41,24 +41,6 @@ provider "registry.opentofu.org/hashicorp/http" {
]
}
provider "registry.opentofu.org/hashicorp/time" {
version = "0.11.1"
constraints = "0.11.1"
hashes = [
"h1:+S9YvR/HeCxFGMS3ITjOFqlWrR6DdarWWowT9Cz18/M=",
"zh:048c56f9f810f67a7460363a26bf3ef939d64f0d7b7342b9e7f24cc85ee1491b",
"zh:49f949cc5cb50fbb65f7b4578b79fbe02b6bafe9e3f5f1c2936114dd445b84b3",
"zh:553174a4fa88f6e186800d7ee155a6b5b4c6c81793643f1a20eab26becc7f823",
"zh:5cae304e21f77091d4b50389c655afd5e4e2e8d4cd9c06de139a31b8e7d343a9",
"zh:7aae20832bd9885f034831aa44db3a6ffcec034a2d5a2815d92c42c40c14ca1d",
"zh:93d715610dce777474b5eff1d7dbe797e72ca0b679cd8636efb3aa45d1cb589e",
"zh:bd29e04645775851eb10e7f3b39104ae57ca3632dec4ae07328d33d4182e7fb5",
"zh:d6ad6a4d52a6989b8452466f2ec3dbcdb00cc44a96bd1ca618d91a5d74895f49",
"zh:e68cfad3ec526631410fa9406938d624fd56b9ab065c76525cb3f731d106fbfe",
"zh:ffee8aa6b7ce56f4b8fdc0c492404be0041137a278388eb1d1180b637fb5b3de",
]
}
provider "registry.opentofu.org/siderolabs/talos" {
version = "0.9.0"
constraints = "0.9.0"

View file

@ -6,6 +6,7 @@ provider "proxmox" {
locals {
cluster_name = "k8s-wheatley"
vm-id_prefix = 200
kubernetes_version = "1.34.1"
talos_version = "1.11.3"
gateway_api_version = "1.4.0"
@ -95,6 +96,7 @@ module "controlplanes" {
for_each = { for node in local.controlplanes.nodes : node.name => node }
node = {
id = local.vm-id_prefix + tonumber(replace(each.key, "cp", ""))
name = format("k8s-wheatley-%s", each.value.name)
ipv4_address = each.value.ip_address
cpu = local.controlplanes.cpu
@ -112,19 +114,14 @@ module "controlplanes" {
}
}
resource "time_sleep" "delay_before_workers" {
depends_on = [module.talos-image]
create_duration = "1s"
}
module "workers" {
depends_on = [time_sleep.delay_before_workers]
depends_on = [module.talos-image]
source = "./modules/talos-node"
for_each = { for node in local.workers.nodes : node.name => node }
node = {
id = local.vm-id_prefix + 20 + tonumber(replace(each.key, "worker", ""))
name = format("k8s-wheatley-%s", each.value.name)
ipv4_address = each.value.ip_address
cpu = local.workers.cpu

View file

@ -38,6 +38,7 @@ cluster:
disabled: true
extraManifests:
- https://github.com/kubernetes-sigs/gateway-api/releases/download/v${gateway-api_version}/standard-install.yaml
- https://raw.githubusercontent.com/alex1989hu/kubelet-serving-cert-approver/main/deploy/standalone-install.yaml
inlineManifests:
- name: cilium-bootstrap
contents: |

View file

@ -33,6 +33,7 @@ cluster:
disabled: true
extraManifests:
- https://github.com/kubernetes-sigs/gateway-api/releases/download/v${gateway-api_version}/standard-install.yaml
- https://raw.githubusercontent.com/alex1989hu/kubelet-serving-cert-approver/main/deploy/standalone-install.yaml
inlineManifests:
- name: cilium-bootstrap
contents: |

View file

@ -8,6 +8,7 @@ terraform {
}
resource "proxmox_virtual_environment_vm" "talos-node" {
vm_id = var.node.id
name = var.node.name
node_name = var.node.proxmox_node
tags = ["tofu"]

View file

@ -1,6 +1,7 @@
variable "node" {
description = "Virtual node configuration"
type = object({
id = number
name = string
ipv4_address = string
ipv4_gateway = string

View file

@ -8,9 +8,5 @@ terraform {
source = "bpg/proxmox"
version = "0.85.1"
}
time = {
source = "hashicorp/time"
version = "0.11.1"
}
}
}