From 4658d799f2b76f623e8f37ddbd592de2ada63bd5 Mon Sep 17 00:00:00 2001 From: Florian Bachinger Date: Mon, 28 Oct 2024 09:53:18 +0100 Subject: [PATCH] create from clone, new provider version --- .gitignore | 4 +++ kubernetes/terraform/main.tf | 8 +++--- kubernetes/terraform/vm_cloud_image.tf | 30 +++++++++++++++++------ kubernetes/terraform/vm_control_planes.tf | 13 ++++++---- kubernetes/terraform/vm_large_worker.tf | 13 ++++++---- kubernetes/terraform/vm_medium_worker.tf | 13 ++++++---- kubernetes/terraform/vm_small_worker.tf | 13 ++++++---- 7 files changed, 63 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 4ae6d2b..e0d8401 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ kubernetes/terraform/secrets_filled.txt +kubernetes/terraform/.terraform +kubernetes/terraform/.terraform.lock.hcl +kubernetes/terraform/terraform.tfstate +kubernetes/terraform/terraform.tfstate.backup diff --git a/kubernetes/terraform/main.tf b/kubernetes/terraform/main.tf index 0758e60..f048b2c 100644 --- a/kubernetes/terraform/main.tf +++ b/kubernetes/terraform/main.tf @@ -3,7 +3,7 @@ terraform { required_providers { proxmox = { source = "bpg/proxmox" - version = "0.59.1" + version = "0.66.3" } } } @@ -15,6 +15,6 @@ provider "proxmox" { insecure = true } -terraform { - backend "local" { path = "/home/spainfra/terraform_state/kubernetes_cluster/terraform.tfstate" } -} \ No newline at end of file +# terraform { +# backend "local" { path = "/home/spainfra/terraform_state/kubernetes_cluster/terraform.tfstate" } +# } \ No newline at end of file diff --git a/kubernetes/terraform/vm_cloud_image.tf b/kubernetes/terraform/vm_cloud_image.tf index cee4320..97d58b5 100644 --- a/kubernetes/terraform/vm_cloud_image.tf +++ b/kubernetes/terraform/vm_cloud_image.tf @@ -1,7 +1,23 @@ -resource "proxmox_virtual_environment_download_file" "CentOS_cloud_image" { - content_type = "iso" - datastore_id = "local" - node_name = var.node_name - url = "https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2" - file_name = "CentOS8-genericcloud_managed_by_spa_terraform_runner_do_not_delete.img" -} \ No newline at end of file +# resource "proxmox_virtual_environment_download_file" "cloud_image" { +# content_type = "iso" +# datastore_id = "local" +# node_name = var.node_name +# url = "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img" +# file_name = "Ubuntu_noble-server-cloudimg_managed_by_spa_terraform_runner_do_not_delete.img" +# } + +# resource "proxmox_virtual_environment_download_file" "cloud_image" { +# content_type = "iso" +# datastore_id = "local" +# node_name = var.node_name +# url = "https://cdimage.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2" +# file_name = "debian-12-cloudimg_managed_by_spa_terraform_runner_do_not_delete.img" +# } + +# resource "proxmox_virtual_environment_download_file" "cloud_image" { +# content_type = "iso" +# datastore_id = "local" +# node_name = var.node_name +# url = "https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-latest.x86_64.qcow2" +# file_name = "CentOS-9-cloudimg_managed_by_spa_terraform_runner_do_not_delete.img" +# } \ No newline at end of file diff --git a/kubernetes/terraform/vm_control_planes.tf b/kubernetes/terraform/vm_control_planes.tf index b975abc..fde66c3 100644 --- a/kubernetes/terraform/vm_control_planes.tf +++ b/kubernetes/terraform/vm_control_planes.tf @@ -1,7 +1,7 @@ resource "proxmox_virtual_environment_vm" "k8s_cp" { count = var.number_of_control_planes - name = "k8s-cp-${count.index}" + name = "k8s-cp-${count.index + 1}" description = "Managed by Terraform" tags = ["terraform"] node_name = var.node_name @@ -23,12 +23,15 @@ resource "proxmox_virtual_environment_vm" "k8s_cp" { vlan_id = var.vlan_id } + clone { + vm_id = 100 + retries = 10 + } + disk { datastore_id = "dellsan" - file_id = proxmox_virtual_environment_download_file.CentOS_cloud_image.id - interface = "virtio0" - iothread = true - discard = "on" + # file_id = proxmox_virtual_environment_download_file.cloud_image.id + interface = "ide0" size = 40 } diff --git a/kubernetes/terraform/vm_large_worker.tf b/kubernetes/terraform/vm_large_worker.tf index d81a3de..e74329b 100644 --- a/kubernetes/terraform/vm_large_worker.tf +++ b/kubernetes/terraform/vm_large_worker.tf @@ -1,7 +1,7 @@ resource "proxmox_virtual_environment_vm" "k8s_worker_large" { count = var.number_of_large_workers - name = "k8s-worker-large-${count.index}" + name = "k8s-worker-large-${count.index + 1}" description = "Managed by Terraform" tags = ["terraform"] node_name = var.node_name @@ -23,12 +23,15 @@ resource "proxmox_virtual_environment_vm" "k8s_worker_large" { vlan_id = var.vlan_id } + clone { + vm_id = 107 + retries = 10 + } + disk { datastore_id = "dellsan" - file_id = proxmox_virtual_environment_download_file.CentOS_cloud_image.id - interface = "virtio0" - iothread = true - discard = "on" + # file_id = proxmox_virtual_environment_download_file.cloud_image.id + interface = "ide0" size = 40 } diff --git a/kubernetes/terraform/vm_medium_worker.tf b/kubernetes/terraform/vm_medium_worker.tf index 2e0061a..21e4be3 100644 --- a/kubernetes/terraform/vm_medium_worker.tf +++ b/kubernetes/terraform/vm_medium_worker.tf @@ -1,7 +1,7 @@ resource "proxmox_virtual_environment_vm" "k8s_worker_medium" { count = var.number_of_medium_workers - name = "k8s-worker-medium-${count.index}" + name = "k8s-worker-medium-${count.index + 1}" description = "Managed by Terraform" tags = ["terraform"] node_name = var.node_name @@ -23,12 +23,15 @@ resource "proxmox_virtual_environment_vm" "k8s_worker_medium" { vlan_id = var.vlan_id } + clone { + vm_id = 109 + retries = 10 + } + disk { datastore_id = "dellsan" - file_id = proxmox_virtual_environment_download_file.CentOS_cloud_image.id - interface = "virtio0" - iothread = true - discard = "on" + # file_id = proxmox_virtual_environment_download_file.cloud_image.id + interface = "ide0" size = 40 } diff --git a/kubernetes/terraform/vm_small_worker.tf b/kubernetes/terraform/vm_small_worker.tf index af0323b..88d9842 100644 --- a/kubernetes/terraform/vm_small_worker.tf +++ b/kubernetes/terraform/vm_small_worker.tf @@ -1,7 +1,7 @@ resource "proxmox_virtual_environment_vm" "k8s_worker_small" { count = var.number_of_small_workers - name = "k8s-worker-small-${count.index}" + name = "k8s-worker-small-${count.index + 1}" description = "Managed by Terraform" tags = ["terraform"] node_name = var.node_name @@ -23,12 +23,15 @@ resource "proxmox_virtual_environment_vm" "k8s_worker_small" { vlan_id = var.vlan_id } + clone { + vm_id = 104 + retries = 10 + } + disk { datastore_id = "dellsan" - file_id = proxmox_virtual_environment_download_file.CentOS_cloud_image.id - interface = "virtio0" - iothread = true - discard = "on" + # file_id = proxmox_virtual_environment_download_file.cloud_image.id + interface = "ide0" size = 40 }