This guide helps you migrate from the deprecated turingpi_k3s_cluster and turingpi_talos_cluster resources to the new terraform-turingpi-modules repository.
The monolithic cluster resources are being replaced with composable Terraform modules that:
- Use native providers: The Talos module uses the official Talos Terraform Provider instead of wrapping
talosctlcommands - Better separation of concerns: Cluster deployment, MetalLB, and Ingress are separate modules you can use independently
- More flexibility: Mix and match addons, use different versions, apply custom configurations
- Easier maintenance: Each module can be updated independently
| Version | Status |
|---|---|
| v1.x | Deprecated cluster resources available with warnings |
| v2.0.0 | Cluster resources removed |
Before migrating, export your cluster's sensitive data:
# For Talos clusters
terraform output -raw kubeconfig > kubeconfig.bak
terraform output -raw talosconfig > talosconfig.bak
terraform output -raw secrets_yaml > secrets.yaml.bak
# For K3s clusters
terraform output -raw kubeconfig > kubeconfig.bakRemove the deprecated resource from Terraform state without destroying the actual cluster:
# For Talos
terraform state rm turingpi_talos_cluster.cluster
# For K3s
terraform state rm turingpi_k3s_cluster.clusterReplace the deprecated resource with the new modules.
Before (deprecated):
resource "turingpi_talos_cluster" "cluster" {
name = "my-cluster"
cluster_endpoint = "https://10.10.88.73:6443"
control_plane {
host = "10.10.88.73"
hostname = "turing-cp1"
}
worker {
host = "10.10.88.74"
hostname = "turing-w1"
}
worker {
host = "10.10.88.75"
hostname = "turing-w2"
}
metallb {
enabled = true
ip_range = "10.10.88.80-10.10.88.89"
}
ingress {
enabled = true
ip = "10.10.88.80"
}
kubeconfig_path = "./kubeconfig"
}After (new modules):
# Deploy Talos cluster using the modules repo
module "cluster" {
source = "freed-dev-llc/modules/turingpi//modules/talos-cluster"
version = "~> 1.4"
cluster_name = "my-cluster"
cluster_endpoint = "https://10.10.88.73:6443"
control_plane = [
{ host = "10.10.88.73", hostname = "turing-cp1" }
]
workers = [
{ host = "10.10.88.74", hostname = "turing-w1" },
{ host = "10.10.88.75", hostname = "turing-w2" }
]
kubeconfig_path = "./kubeconfig"
}
# Configure providers for addons
provider "helm" {
kubernetes {
config_path = module.cluster.kubeconfig_path
}
}
provider "kubectl" {
config_path = module.cluster.kubeconfig_path
}
# Deploy MetalLB separately
module "metallb" {
source = "freed-dev-llc/modules/turingpi//modules/addons/metallb"
version = "~> 1.4"
depends_on = [module.cluster]
ip_range = "10.10.88.80-10.10.88.89"
}
# Deploy Ingress-NGINX separately
module "ingress" {
source = "freed-dev-llc/modules/turingpi//modules/addons/ingress-nginx"
version = "~> 1.4"
depends_on = [module.metallb]
loadbalancer_ip = "10.10.88.80"
}Before (deprecated):
resource "turingpi_k3s_cluster" "cluster" {
name = "my-cluster"
control_plane {
host = "10.10.88.73"
ssh_user = "root"
ssh_key = file("~/.ssh/id_rsa")
}
worker {
host = "10.10.88.74"
ssh_user = "root"
ssh_key = file("~/.ssh/id_rsa")
}
metallb {
enabled = true
ip_range = "10.10.88.80-10.10.88.89"
}
}After (new modules):
For K3s, you'll need to use a community K3s Terraform module or manage the cluster manually. The terraform-turingpi-modules focuses on Talos as the recommended distribution.
If you want to manage an existing cluster with the new modules, you may need to import state. The Talos provider supports importing existing clusters:
# Import machine secrets (you'll need the secrets from your backup)
terraform import module.cluster.talos_machine_secrets.this <cluster-name>Run Terraform to verify the configuration:
terraform init
terraform plan
terraform apply| Feature | Old Resource | New Modules |
|---|---|---|
| Talos operations | Wraps talosctl CLI |
Native Talos provider |
| Addons | Built into resource | Separate modules |
| Configuration | Single resource | Composable modules |
| State management | Monolithic | Per-module |
| Customization | Limited | Full Helm values support |
This is expected. The cluster still exists but Terraform no longer manages it. After adding the new modules, run terraform plan to see what changes would be applied.
If you're getting errors about existing MetalLB or Ingress resources, you may need to clean up the existing installations first:
kubectl delete namespace metallb-system
kubectl delete namespace ingress-nginxThen apply your Terraform configuration.
Ensure your providers are configured correctly:
provider "helm" {
kubernetes {
config_path = "./kubeconfig"
}
}
provider "kubectl" {
config_path = "./kubeconfig"
}