-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcloud-init.tf
50 lines (46 loc) · 1.98 KB
/
cloud-init.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
resource "proxmox_virtual_environment_file" "cloud-init-kubernetes-controlplane" {
node_name = var.node_name
content_type = "snippets"
datastore_id = var.cloud_init_configuration_datastore_id
source_raw {
data = templatefile("${path.module}/cloud-init/ctrl.yaml.tftpl", {
#defaults
hostname = var.vm_name
user = var.user
user_password = var.user_password
user_pub_key = var.user_pub_key
timezone = var.cloud_init_configuration_timezone
#apt related
apt_mirror_primary = var.cloud_init_configuration_apt_primary_mirror_uri
apt_mirror_security = var.cloud_init_configuration_apt_security_mirror_uri
#kube related
kubernetes_version = var.kubernetes_version
kubeadm_cmd = "kubeadm init --skip-phases=addon/kube-proxy"
})
file_name = format("%s.yaml","cloud-init-kubernetes-controlplane")
}
}
resource "proxmox_virtual_environment_file" "cloud-init-kubernetes-worker" {
depends_on = [ module.kubeadm-join ] #create only after control plane is done
for_each = { for each in var.workers : each.name => each }
node_name = each.value.node
content_type = "snippets"
datastore_id = var.cloud_init_configuration_datastore_id
source_raw {
data = templatefile("${path.module}/cloud-init/worker.yaml.tftpl", {
#defaults
hostname = each.value.name
user = var.user
user_password = var.user_password
user_pub_key = var.user_pub_key
timezone = var.cloud_init_configuration_timezone
#apt related
apt_mirror_primary = var.cloud_init_configuration_apt_primary_mirror_uri
apt_mirror_security = var.cloud_init_configuration_apt_security_mirror_uri
#kube related
kubernetes_version = var.kubernetes_version
kubeadm_cmd = module.kubeadm-join.stdout
})
file_name = format("%s-%s.yaml","cloud-init-kubernetes-worker",each.value.name)
}
}