-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.tf
64 lines (50 loc) · 1.4 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
provider "hcloud" {
token = var.hcloud_token
}
resource "hcloud_network" "private" {
name = var.cluster_name
ip_range = "10.0.0.0/8"
}
resource "hcloud_network_subnet" "subnet" {
network_id = hcloud_network.private.id
type = "cloud"
network_zone = "eu-central"
ip_range = "10.0.0.0/24"
}
resource "random_string" "k3s_token" {
length = 48
upper = false
special = false
}
module "master" {
source = "./modules/master"
cluster_name = var.cluster_name
datacenter = var.datacenter
image = var.image
node_type = var.master_type
ssh_keys = var.ssh_keys
hcloud_network_id = hcloud_network.private.id
hcloud_subnet_id = hcloud_network_subnet.subnet.id
k3s_token = random_string.k3s_token.result
k3s_channel = var.k3s_channel
hcloud_token = var.hcloud_token
}
module "node_group" {
source = "./modules/node_group"
cluster_name = var.cluster_name
datacenter = var.datacenter
image = var.image
ssh_keys = var.ssh_keys
master_ipv4 = module.master.master_ipv4
hcloud_subnet_id = hcloud_network_subnet.subnet.id
k3s_token = random_string.k3s_token.result
k3s_channel = var.k3s_channel
for_each = var.node_groups
node_type = each.key
node_count = each.value
}
module "kubeconfig" {
source = "./modules/kubeconfig"
cluster_name = var.cluster_name
master_ipv4 = module.master.master_ipv4
}