forked from linode/terraform-linode-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.tf
73 lines (61 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
69
70
71
72
73
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))}"]
root_pass = "${random_string.password.result}"
image = "linode/ubuntu16.04lts"
}
config {
label = "node"
kernel = "linode/grub2"
devices {
sda = {
disk_label = "boot"
}
}
}
provisioner file {
source = "config/sshd_config"
destination = "/etc/ssh/sshd_config"
}
provisioner remote-exec {
inline = [
"systemctl restart sshd",
]
}
provisioner "file" {
source = "scripts/docker-install.sh"
destination = "/tmp/docker-install.sh"
}
provisioner "file" {
source = "scripts/kubeadm-install.sh"
destination = "/tmp/kubeadm-install.sh"
}
provisioner "remote-exec" {
inline = [
"set -e",
"hostnamectl set-hostname ${self.label} && hostname -F /etc/hostname",
"chmod +x /tmp/docker-install.sh && /tmp/docker-install.sh ${var.docker_version}",
"chmod +x /tmp/kubeadm-install.sh && /tmp/kubeadm-install.sh ${var.kubeadm_version}",
"${data.external.kubeadm_join.result.command}",
]
}
provisioner "remote-exec" {
inline = [
"kubectl get pods --all-namespaces",
]
on_failure = "continue"
connection {
type = "ssh"
user = "root"
host = "${linode_instance.k8s_master.0.ip_address}"
}
}
}