forked from linode/terraform-linode-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
83 lines (69 loc) · 2.47 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
provider "linode" {
token = "${var.linode_token}"
version = "1.5.0"
}
provider "external" {
version = "1.0.0"
}
resource "null_resource" "preflight-checks" {
# Force re-run
triggers {
key = "${uuid()}"
}
provisioner "local-exec" {
command = "${path.module}/scripts/local/preflight.sh"
}
}
module "masters" {
source = "./modules/masters"
label_prefix = "${var.cluster_name == "" ? terraform.workspace : var.cluster_name}"
node_class = "master"
node_count = "${var.masters}"
node_type = "${var.server_type_master}"
linode_token = "${var.linode_token}"
k8s_version = "${var.k8s_version}"
crictl_version = "${var.crictl_version}"
k8s_feature_gates = "${var.k8s_feature_gates}"
cni_version = "${var.cni_version}"
ssh_public_key = "${var.ssh_public_key}"
region = "${var.region}"
linode_group = "${var.cluster_name}"
//todo variable instead of workspace?
cluster_name = "${var.cluster_name == "" ? terraform.workspace : var.cluster_name}"
}
module "nodes" {
source = "./modules/nodes"
label_prefix = "${var.cluster_name == "" ? terraform.workspace : var.cluster_name}"
node_class = "node"
node_count = "${var.nodes}"
node_type = "${var.server_type_node}"
k8s_version = "${var.k8s_version}"
crictl_version = "${var.crictl_version}"
k8s_feature_gates = "${var.k8s_feature_gates}"
cni_version = "${var.cni_version}"
ssh_public_key = "${var.ssh_public_key}"
region = "${var.region}"
linode_group = "${var.cluster_name}"
kubeadm_join_command = "${module.masters.kubeadm_join_command}"
}
resource "null_resource" "local_kubectl" {
// todo
depends_on = ["module.masters"]
provisioner "local-exec" {
command = "${path.module}/scripts/local/kubectl-conf.sh ${terraform.workspace} ${module.masters.k8s_master_public_ip} ${module.masters.k8s_master_private_ip} ${var.ssh_public_key}"
on_failure = "continue"
}
}
resource "null_resource" "update-agent" {
depends_on = ["module.masters", "module.nodes"]
triggers {
cluster_ips = "${"${module.masters.k8s_master_public_ip} ${join(" ", module.nodes.nodes_public_ip)}"}"
}
provisioner "remote-exec" {
connection {
host = "${module.masters.k8s_master_public_ip}"
user = "core"
}
inline = ["/opt/bin/kubectl annotate node --all --overwrite container-linux-update.v1.coreos.com/reboot-paused=${var.update_agent_reboot_paused}"]
}
}