Skip to content

Commit 5d1c787

Browse files
authored
Merge pull request #27 from max-pfeiffer/feature/switch-proxmox-provider
Switched to BGP Proxmox provider
2 parents 76a5950 + 7aadd74 commit 5d1c787

8 files changed

Lines changed: 147 additions & 107 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre
158158
* [Cilium documentation](https://docs.cilium.io/en/stable/)
159159
* [Gateway API](https://gateway-api.sigs.k8s.io/)
160160
* Terraform providers:
161-
* [terraform-provider-proxmox](https://github.com/Telmate/terraform-provider-proxmox)
161+
* [terraform-provider-proxmox](https://github.com/bpg/terraform-provider-proxmox)
162162
* [terraform-provider-talos](https://github.com/siderolabs/terraform-provider-talos)
163163
* [terraform-provider-kubernetes](https://github.com/hashicorp/terraform-provider-kubernetes)
164164
* [terraform-provider-helm](https://github.com/hashicorp/terraform-provider-helm)

proxmox/.terraform.lock.hcl

Lines changed: 34 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proxmox/configuration.auto.tfvars.advanced-example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Proxmox
2-
proxmox_api_url = "https://192.168.1.25:8006/api2/json"
2+
proxmox_api_url = "https://192.168.1.25:8006/"
33
proxmox_api_token_id = "root@pam!supersecret"
44
proxmox_api_token_secret = "js7ej5k9-hd75-hd64-js56-js834jmd732"
55
proxmox_target_node = "your-proxmox-node"

proxmox/configuration.auto.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Proxmox
2-
proxmox_api_url = "https://192.168.1.25:8006/api2/json"
2+
proxmox_api_url = "https://192.168.1.25:8006/"
33
proxmox_api_token_id = "root@pam!supersecret"
44
proxmox_api_token_secret = "js7ej5k9-hd75-hd64-js56-js834jmd732"
55
proxmox_target_node = "your-proxmox-node"

proxmox/iso_images.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
resource "proxmox_storage_iso" "talos_linux_iso_image" {
2-
url = var.talos_linux_iso_image_url
3-
filename = var.talos_linux_iso_image_filename
4-
storage = "local"
5-
pve_node = var.proxmox_target_node
1+
resource "proxmox_download_file" "talos_linux_iso_image" {
2+
content_type = "iso"
3+
datastore_id = "local"
4+
node_name = var.proxmox_target_node
5+
url = var.talos_linux_iso_image_url
6+
file_name = var.talos_linux_iso_image_filename
67
}

proxmox/providers.tf

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
terraform {
22
required_providers {
33
proxmox = {
4-
source = "telmate/proxmox"
5-
version = "3.0.2-rc07"
4+
source = "bpg/proxmox"
5+
version = "0.111.1"
66
}
77
talos = {
88
source = "siderolabs/talos"
@@ -16,11 +16,8 @@ terraform {
1616
}
1717

1818
provider "proxmox" {
19-
pm_api_url = var.proxmox_api_url
20-
pm_api_token_id = var.proxmox_api_token_id
21-
pm_api_token_secret = var.proxmox_api_token_secret
22-
pm_tls_insecure = true
23-
# Switching off parallelism is necessary here, as VM provisioning fails otherwise
24-
# see: https://github.com/Telmate/terraform-provider-proxmox/issues/173
25-
pm_parallel = 1
19+
# bpg/proxmox expects the plain endpoint without the /api2/json path
20+
endpoint = trimsuffix(var.proxmox_api_url, "/api2/json")
21+
api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
22+
insecure = true
2623
}

proxmox/talos_linux.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data "talos_client_configuration" "this" {
2525
}
2626

2727
resource "talos_machine_configuration_apply" "controlplane" {
28-
depends_on = [proxmox_vm_qemu.kubernetes_control_plane]
28+
depends_on = [proxmox_virtual_environment_vm.kubernetes_control_plane]
2929
client_configuration = talos_machine_secrets.this.client_configuration
3030
machine_configuration_input = data.talos_machine_configuration.controlplane.machine_configuration
3131
for_each = var.node_data.controlplanes
@@ -50,7 +50,7 @@ resource "talos_machine_configuration_apply" "controlplane" {
5050
}
5151

5252
resource "talos_machine_configuration_apply" "worker" {
53-
depends_on = [proxmox_vm_qemu.kubernetes_worker]
53+
depends_on = [proxmox_virtual_environment_vm.kubernetes_worker]
5454
client_configuration = talos_machine_secrets.this.client_configuration
5555
machine_configuration_input = data.talos_machine_configuration.worker.machine_configuration
5656
for_each = var.node_data.workers

proxmox/virtual_machines.tf

Lines changed: 96 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,134 @@
1-
resource "proxmox_vm_qemu" "kubernetes_control_plane" {
2-
depends_on = [proxmox_storage_iso.talos_linux_iso_image]
3-
for_each = var.node_data.controlplanes
4-
name = format("%s-kubernetes-control-plane-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key))
5-
description = "Kubernetes Control Plane"
6-
target_node = var.proxmox_target_node
7-
agent = 1
8-
vm_state = "running"
9-
memory = 8192
10-
boot = "order=virtio0;ide2"
11-
nameserver = var.domain_name_server
1+
resource "proxmox_virtual_environment_vm" "kubernetes_control_plane" {
2+
depends_on = [proxmox_download_file.talos_linux_iso_image]
3+
for_each = var.node_data.controlplanes
4+
name = format("%s-kubernetes-control-plane-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key))
5+
description = "Kubernetes Control Plane"
6+
node_name = var.proxmox_target_node
7+
started = true
8+
stop_on_destroy = true
9+
boot_order = ["virtio0", "ide2"]
10+
11+
agent {
12+
enabled = true
13+
}
14+
15+
operating_system {
16+
type = "l26"
17+
}
1218

1319
cpu {
1420
cores = 2
21+
type = "host"
1522
}
1623

17-
vga {
18-
type = "std"
24+
memory {
25+
dedicated = 8192
1926
}
2027

21-
disk {
22-
slot = "ide0"
23-
type = "cloudinit"
24-
storage = var.proxmox_storage_device
28+
vga {
29+
type = "std"
2530
}
2631

27-
disk {
28-
slot = "ide2"
29-
type = "cdrom"
30-
iso = "local:iso/${var.talos_linux_iso_image_filename}"
32+
cdrom {
33+
interface = "ide2"
34+
file_id = proxmox_download_file.talos_linux_iso_image.id
3135
}
3236

3337
disk {
34-
slot = "virtio0"
35-
type = "disk"
36-
storage = var.proxmox_storage_device
37-
size = "50G"
38-
discard = true
38+
interface = "virtio0"
39+
datastore_id = var.proxmox_storage_device
40+
size = 50
41+
discard = "on"
3942
}
4043

41-
network {
42-
id = 0
43-
model = "virtio"
44-
bridge = "vmbr0"
45-
tag = var.vlan_tag
44+
network_device {
45+
model = "virtio"
46+
bridge = "vmbr0"
47+
vlan_id = var.vlan_tag
4648
}
4749

4850
# Cloud init setup
49-
os_type = "cloud-init"
50-
ipconfig0 = "ip=${each.key}/24,gw=${var.network_gateway}"
51+
initialization {
52+
interface = "ide0"
53+
datastore_id = var.proxmox_storage_device
54+
55+
ip_config {
56+
ipv4 {
57+
address = "${each.key}/24"
58+
gateway = var.network_gateway
59+
}
60+
}
61+
62+
dns {
63+
servers = [var.domain_name_server]
64+
}
65+
}
5166
}
5267

5368

54-
resource "proxmox_vm_qemu" "kubernetes_worker" {
55-
depends_on = [proxmox_storage_iso.talos_linux_iso_image]
56-
for_each = var.node_data.workers
57-
name = format("%s-kubernetes-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key))
58-
description = "Kubernetes Worker Node"
59-
target_node = var.proxmox_target_node
60-
agent = 1
61-
vm_state = "running"
62-
memory = 16384
63-
boot = "order=virtio0;ide2"
64-
nameserver = var.domain_name_server
69+
resource "proxmox_virtual_environment_vm" "kubernetes_worker" {
70+
depends_on = [proxmox_download_file.talos_linux_iso_image]
71+
for_each = var.node_data.workers
72+
name = format("%s-kubernetes-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key))
73+
description = "Kubernetes Worker Node"
74+
node_name = var.proxmox_target_node
75+
started = true
76+
stop_on_destroy = true
77+
boot_order = ["virtio0", "ide2"]
78+
79+
agent {
80+
enabled = true
81+
}
82+
83+
operating_system {
84+
type = "l26"
85+
}
6586

6687
cpu {
6788
cores = 2
89+
type = "host"
6890
}
6991

70-
vga {
71-
type = "std"
92+
memory {
93+
dedicated = 16384
7294
}
7395

74-
disk {
75-
slot = "ide0"
76-
type = "cloudinit"
77-
storage = var.proxmox_storage_device
96+
vga {
97+
type = "std"
7898
}
7999

80-
disk {
81-
slot = "ide2"
82-
type = "cdrom"
83-
iso = "local:iso/${var.talos_linux_iso_image_filename}"
100+
cdrom {
101+
interface = "ide2"
102+
file_id = proxmox_download_file.talos_linux_iso_image.id
84103
}
85104

86105
disk {
87-
slot = "virtio0"
88-
type = "disk"
89-
storage = var.proxmox_storage_device
90-
size = "50G"
91-
discard = true
106+
interface = "virtio0"
107+
datastore_id = var.proxmox_storage_device
108+
size = 50
109+
discard = "on"
92110
}
93111

94-
network {
95-
id = 0
96-
model = "virtio"
97-
bridge = "vmbr0"
98-
tag = var.vlan_tag
112+
network_device {
113+
model = "virtio"
114+
bridge = "vmbr0"
115+
vlan_id = var.vlan_tag
99116
}
100117

101118
# Cloud init setup
102-
os_type = "cloud-init"
103-
ipconfig0 = "ip=${each.key}/24,gw=${var.network_gateway}"
119+
initialization {
120+
interface = "ide0"
121+
datastore_id = var.proxmox_storage_device
122+
123+
ip_config {
124+
ipv4 {
125+
address = "${each.key}/24"
126+
gateway = var.network_gateway
127+
}
128+
}
129+
130+
dns {
131+
servers = [var.domain_name_server]
132+
}
133+
}
104134
}

0 commit comments

Comments
 (0)