Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Terraform module to provision a Kubernetes cluster on Proxmox using Talos Linux. Automates node creation, Talos configuration, and integration with Proxmox, providing a secure and lightweight environment for homelabs or production use. Ideal for streamlined Kubernetes setup and management.

License

Notifications You must be signed in to change notification settings

pascalinthecloud/terraform-proxmox-talos-cluster

Repository files navigation

terraform-proxmox-talos-cluster

A Terraform module for provisioning a Kubernetes cluster on Proxmox using Talos Linux. This module automates node creation, Talos configuration, and Proxmox integration, offering a secure, lightweight, and efficient environment for homelabs or production use. It simplifies the Kubernetes setup and management process.

Feel free to contact me, open an issue, or contribute to the project. Your feedback and contributions are always welcome! 🤓

Geting kubeconfig & talosconfig

terraform output --raw kubeconfig > cluster.kubeconfig
terraform output --raw talosconfig > cluster.talosconfig

Upgrading Talos cluster

First we need get the schematic id from the outputs and use that for upgrading the cluster in order to keep the extensions.

talosctl upgrade --image factory.talos.dev/installer/<SCHEMATIC_ID>:v1.9.3 --preserve

The preserve option is only needed when wanting to keep files/directories on Talos nodes (for example when using Longhorn/Rook...)

Example

module "k8s_cluster" {
  source       = "../modules/k8s_cluster"
  
  cluster = {
    name = "homelab.cluster"
    vm_base_id   = 700
    datastore    = "local-lvm"
    node         = "pve01"
    config_patches = [file("${path.module}/config_patch.yaml")]
  }
 
  image = {
    version    = "v1.9.1"
    extensions = ["qemu-guest-agent", "iscsi-tools", "util-linux-tools"]
  }

  network = {
    cidr        = "10.10.100.0/24"
    gateway     = "10.10.100.1"
    dns_servers = ["10.0.10.1", "1.1.1.1"]
    vlan_id     = 1100
  }

  controlplane = {
    count = 1
    specs = {
      cpu    = 2
      memory = 4096
      disk   = 50
    }
  }

  worker = {
    count = 2
    specs = {
      cpu    = 2
      memory = 6192
      disk   = 50
    }
  }
}

# Override example 
module "k8s_cluster_override" {
  source       = "../modules/k8s_cluster"
  
  cluster = {
    name = "homelab.cluster"
    vm_base_id   = 700
    datastore    = "local-lvm"
    node         = "pve01"
    config_patches = [file("${path.module}/config_patch.yaml")]
  }
 
  image = {
    version    = "v1.9.1"
    extensions = ["qemu-guest-agent", "iscsi-tools", "util-linux-tools"]
  }

  network = {
    cidr        = "10.10.100.0/24"
    gateway     = "10.10.100.1"
    dns_servers = ["10.0.10.1", "1.1.1.1"]
    vlan_id     = 1100
  }

  controlplane = {
    count = 1
    specs = {
      cpu    = 2
      memory = 4096
      disk   = 50
    }
  }

  worker = {
    count = 2
    specs = {
      cpu    = 2
      memory = 6192
      disk   = 50
    }
  }
  overrides = {
    "controlplane-1" = {
      node = "pve01"
      network = {
        cidr        = "10.10.101.0/24"
        ip_address  = "10.10.101.150"
        gateway     = "10.10.101.1"
        dns_servers = ["10.0.10.1", "1.1.1.1"]
        vlan_id     = 1101
      }
    }
  }
}

Providers

Name Version
proxmox >= 0.69.0, < 1.0.0
talos >= 0.7.0, < 1.0.0

Requirements

Name Version
terraform >= 1.9.2
proxmox >= 0.69.0, < 1.0.0
talos >= 0.7.0, < 1.0.0

Inputs

Name Description Type Default Required
cluster Cluster configuration
object({
name = string # The name of the cluster
config_patches = list(string) # List of configuration patches to apply to the Talos machine configuration
node = string # Default node to deploy the vms on
datastore = string # Default datastore to deploy the vms on
vm_base_id = number # The first VM ID for Proxmox VMs, with subsequent IDs counted up from it
install_disk = optional(string, "/dev/sda") # The disk to install Talos on
})
n/a yes
controlplane Specification of controlplane nodes
object({
count = number
specs = object({
cpu = number
memory = number
disk = number
})
overrides = optional(map(object({
datastore = optional(string, null)
node = optional(string, null)
cpu = optional(number, null)
memory = optional(number, null)
disk = optional(number, null)
install_disk = optional(string, null)
network = optional(object({
ip_address = string
cidr = string
gateway = string
vlan_id = optional(number, null)
}), null)
})), {})
})
n/a yes
image Variable to define the image configuration for Talos machines
object({
version = string
extensions = list(string)
factory_url = optional(string, "https://factory.talos.dev")
arch = optional(string, "amd64")
platform = optional(string, "nocloud")
proxmox_datastore = optional(string, "local")
})
n/a yes
network Network configuration for nodes
object({
cidr = string
gateway = string
dns_servers = list(string)
vlan_id = optional(number, null)
})
n/a yes
worker Specification of worker nodes
object({
count = number
specs = object({
cpu = number
memory = number
disk = number
})
overrides = optional(map(object({
datastore = optional(string, null)
node = optional(string, null)
cpu = optional(number, null)
memory = optional(number, null)
disk = optional(number, null)
install_disk = optional(string, null)
network = optional(object({
ip_address = string
cidr = string
gateway = string
vlan_id = optional(number, null)
}), null)
})), {})
})
n/a yes

Outputs

Name Description
kubeconfig Kubernetes kubeconfig for the cluster
talos_cluster_health Health status of the Talos cluster, can be used for other ressources to depend on
talos_image_schematic_id ID of the Talos image schematic
talosconfig Talos configuration file for the cluster

Repo Activity

Alt

About

Terraform module to provision a Kubernetes cluster on Proxmox using Talos Linux. Automates node creation, Talos configuration, and integration with Proxmox, providing a secure and lightweight environment for homelabs or production use. Ideal for streamlined Kubernetes setup and management.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages