forked from linode/terraform-linode-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.tf
68 lines (58 loc) · 1.64 KB
/
nodes.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
resource "linode_instance" "k8s_node" {
count = "${var.nodes}"
region = "${var.region}"
label = "${terraform.workspace}-node-${count.index + 1}"
group = "${var.linode_group}"
type = "${var.server_type_node}"
private_ip = true
disk {
label = "boot"
size = 81920
authorized_keys = ["${chomp(file(var.ssh_public_key))}"]
image = "linode/containerlinux"
}
config {
label = "node"
kernel = "linode/direct-disk"
devices {
sda = {
disk_label = "boot"
}
}
}
provisioner "file" {
source = "scripts/"
destination = "/tmp"
connection {
user = "core"
timeout = "300s"
}
}
provisioner "remote-exec" {
inline = [
"set -e",
"chmod +x /tmp/start.sh && sudo /tmp/start.sh",
"chmod +x /tmp/node-iptables.sh && sudo /tmp/node-iptables.sh",
"chmod +x /tmp/linode-network.sh && sudo /tmp/linode-network.sh ${self.private_ip_address} ${self.label}",
"chmod +x /tmp/kubeadm-install.sh && sudo /tmp/kubeadm-install.sh ${var.k8s_version} ${var.cni_version} ${self.label} ${self.private_ip_address}",
"export PATH=$${PATH}:/opt/bin",
"sudo ${data.external.kubeadm_join.result.command}",
"chmod +x /tmp/end.sh && sudo /tmp/end.sh",
]
connection {
user = "core"
timeout = "300s"
}
}
provisioner "remote-exec" {
inline = [
"kubectl get pods --all-namespaces",
]
on_failure = "continue"
connection {
user = "core"
timeout = "300s"
host = "${linode_instance.k8s_master.0.ip_address}"
}
}
}