-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
171 lines (152 loc) · 6.28 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
terraform {
required_version = ">= 1.7.0"
required_providers {
# see https://registry.terraform.io/providers/hashicorp/random
# see https://github.com/hashicorp/terraform-provider-random
random = {
source = "hashicorp/random"
version = ">= 3.6.3"
}
# see https://registry.terraform.io/providers/bpg/proxmox
# see https://github.com/bpg/terraform-provider-proxmox
proxmox = {
source = "bpg/proxmox"
version = ">= 0.66.1"
}
# see https://registry.terraform.io/providers/siderolabs/talos
# see https://github.com/siderolabs/terraform-provider-talos
talos = {
source = "siderolabs/talos"
version = ">= 0.6.0"
}
# see https://registry.terraform.io/providers/hashicorp/helm
# see https://github.com/hashicorp/terraform-provider-helm
helm = {
source = "hashicorp/helm"
version = ">= 2.15.0"
}
# see https://registry.terraform.io/providers/hashicorp/time
# see https://github.com/hashicorp/terraform-provider-time
time = {
source = "hashicorp/time"
version = ">= 0.12.1"
}
# see https://registry.terraform.io/providers/fluxcd/flux/latest/docs
# see https://github.com/fluxcd/terraform-provider-flux
flux = {
source = "fluxcd/flux"
version = ">= 1.2"
}
# see https://registry.terraform.io/providers/integrations/github/latest
# see https://github.com/integrations/terraform-provider-github
github = {
source = "integrations/github"
version = ">= 6.3.0"
}
# see https://registry.terraform.io/providers/ivoronin/macaddress
# see https://github.com/ivoronin/terraform-provider-macaddress
macaddress = {
source = "ivoronin/macaddress"
version = ">= 0.3.2"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_api_url
# TODO: use terraform variable or remove the line, and use PROXMOX_VE_API_TOKEN environment variable
api_token = "${var.proxmox_user}!${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
# because self-signed TLS certificate is in use
insecure = true
# uncomment (unless on Windows...)
tmp_dir = "/var/tmp"
ssh {
agent = true
username = var.proxmox_user
}
}
locals {
talos_iso_image_location = "${var.talos_iso_destination_storage_pool}:iso/${replace(var.talos_iso_destination_filename, "%version%", var.talos_version)}"
talos_k8s_cluster_endpoint = "https://${var.talos_k8s_cluster_domain}:${var.talos_k8s_cluster_endpoint_port}"
}
module "talos_iso" {
source = "./modules/download_talos_iso"
providers = {
proxmox = proxmox
talos = talos
}
talos_iso_destination_filename = var.talos_iso_destination_filename
talos_iso_destination_server = var.talos_iso_destination_server
talos_iso_destination_storage_pool = var.talos_iso_destination_storage_pool
talos_version = var.talos_version
proxmox_nodes = var.proxmox_nodes
}
module "control_plane_vms" {
depends_on = [ module.talos_iso ]
source = "./modules/create_vms_control_plane"
providers = {
macaddress = macaddress
proxmox = proxmox
}
proxmox_nodes = var.proxmox_nodes
control_plane_first_id = var.control_plane_first_id
control_plane_first_ip = var.control_plane_first_ip
talos_network_dhcp = var.talos_network_dhcp
talos_network_cidr = var.talos_network_cidr
talos_network_gateway = var.talos_network_gateway
talos_version = var.talos_version
talos_iso_image_location = local.talos_iso_image_location
control_plane_name_prefix = var.control_plane_name_prefix
}
module "workers_vms" {
depends_on = [ module.talos_iso ]
source = "./modules/create_vms_workers"
providers = {
macaddress = macaddress
proxmox = proxmox
}
proxmox_nodes = var.proxmox_nodes
worker_node_first_id = var.worker_node_first_id
worker_node_first_ip = var.worker_node_first_ip
talos_network_dhcp = var.talos_network_dhcp
talos_network_cidr = var.talos_network_cidr
talos_network_gateway = var.talos_network_gateway
talos_version = var.talos_version
talos_iso_image_location = local.talos_iso_image_location
worker_node_name_prefix = var.worker_node_name_prefix
}
module "create_talos_config" {
depends_on = [ module.control_plane_vms, module.workers_vms, module.talos_iso ]
source = "./modules/create_talos_config"
providers = {
talos = talos
}
talos_k8s_cluster_domain = var.talos_k8s_cluster_domain
talos_k8s_cluster_endpoint_port = var.talos_k8s_cluster_endpoint_port
talos_k8s_cluster_name = var.talos_k8s_cluster_name
talos_k8s_cluster_vip = var.talos_k8s_cluster_vip
talos_version = var.talos_version
talos_network_gateway = var.talos_network_gateway
k8s_version = var.k8s_version
talos_install_disk_device = var.talos_install_disk_device
talos_control_plane_vms_network = module.control_plane_vms.talos_control_plane_vms_network
talos_install_image_url = module.talos_iso.talos_image_url
}
module "boot_talos_nodes" {
depends_on = [ module.create_talos_config ]
source = "./modules/boot_talos_nodes"
providers = {
talos = talos
}
talos_k8s_cluster_name = var.talos_k8s_cluster_name
talos_k8s_cluster_endpoint = local.talos_k8s_cluster_endpoint
talos_k8s_cluster_domain = var.talos_k8s_cluster_domain
talos_k8s_cluster_endpoint_port = var.talos_k8s_cluster_endpoint_port
talos_k8s_cluster_vip = var.talos_k8s_cluster_vip
talos_network_gateway = var.talos_network_gateway
talos_network_ip_prefix = var.talos_network_ip_prefix
control_planes_network = module.control_plane_vms.talos_control_plane_vms_network
workers_network = module.workers_vms.talos_worker_network
talos_machine_configuration_control_planes = module.create_talos_config.talos_machine_configuration_control_planes
talos_machine_configuration_workers = module.create_talos_config.talos_machine_configuration_workers
talos_machine_secrets = module.create_talos_config.talos_machine_secrets
}