forked from cktf/terraform-hcloud-rke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmasters.tf
58 lines (50 loc) · 2.02 KB
/
masters.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
resource "hcloud_placement_group" "this" {
name = var.name
type = "spread"
}
resource "hcloud_server" "this" {
for_each = var.masters
depends_on = [var.network_id]
name = "${var.name}-master-${each.key}"
server_type = each.value.type
image = "ubuntu-20.04"
location = each.value.location
ssh_keys = [hcloud_ssh_key.this.id]
placement_group_id = hcloud_placement_group.this.id
labels = merge(try(each.value.tags, {}), { "hcloud/master" = var.name })
user_data = templatefile("${path.module}/templates/create.sh", {
type = var.type
channel = var.channel
version = var.version_
registries = var.registries
pods_cidr = var.pods_cidr
taints = try(each.value.taints, {})
labels = try(each.value.labels, {})
extra_args = try(each.value.extra_args, [])
extra_envs = try(each.value.extra_envs, {})
pre_create_user_data = try(each.value.pre_create_user_data, "")
post_create_user_data = try(each.value.post_create_user_data, "")
leader = (each.key == keys(var.masters)[0])
private_ip = hcloud_load_balancer_network.this.ip
public_ip = hcloud_load_balancer.this.ipv4
cluster_token = random_string.cluster_token.result
agent_token = random_string.agent_token.result
bootstrap_file = templatefile("${path.module}/templates/manifests/bootstrap.yml", {
token_id = random_string.token_id.result
token_secret = random_string.token_secret.result
})
ccm_file = templatefile("${path.module}/templates/manifests/ccm.yml", {
pods_cidr = var.pods_cidr
hcloud_token = var.hcloud_token
hcloud_network = var.network_id
})
csi_file = templatefile("${path.module}/templates/manifests/csi.yml", {
hcloud_token = var.hcloud_token
})
})
}
resource "hcloud_server_network" "this" {
for_each = var.masters
server_id = hcloud_server.this[each.key].id
network_id = var.network_id
}