-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnodes.tf
More file actions
86 lines (68 loc) · 1.99 KB
/
Copy pathnodes.tf
File metadata and controls
86 lines (68 loc) · 1.99 KB
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
84
85
86
resource "aws_launch_configuration" "nodes" {
name_prefix = "node-"
image_id = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.large"
security_groups = [
"${aws_security_group.ssh.id}",
"${aws_security_group.icmp.id}",
"${aws_security_group.egress.id}",
"${aws_security_group.kube.id}",
"${aws_security_group.LBPorts.id}",
]
iam_instance_profile = "${aws_iam_instance_profile.nodes.name}"
key_name = "${aws_key_pair.kube.key_name}"
lifecycle {
create_before_destroy = true
}
root_block_device {
volume_type = "gp2"
volume_size = 20
delete_on_termination = true
}
associate_public_ip_address = true
user_data = "${data.template_cloudinit_config.nodes.rendered}"
}
resource "aws_autoscaling_group" "nodes" {
name = "nodes"
launch_configuration = "${aws_launch_configuration.nodes.name}"
desired_capacity = "${var.nodes_num}"
min_size = "${var.nodes_num}"
max_size = "${var.max_nodes}"
termination_policies = ["OldestInstance"]
health_check_type = "EC2"
vpc_zone_identifier = ["${aws_subnet.public.*.id}"]
lifecycle {
create_before_destroy = true
}
tag {
key = "Name"
value = "nodes"
propagate_at_launch = true
}
tag {
key = "kubernetes.io/cluster/${var.stage}"
value = ""
propagate_at_launch = true
}
tag {
key = "foo"
value = "bar"
propagate_at_launch = true
}
depends_on = ["aws_instance.control_plane"]
}
data "template_file" "nodes" {
template = "${file("${path.root}/nodes.tpl")}"
vars {
k8s_token = "${var.k8s_token}"
control_plane_ip = "${aws_instance.control_plane.private_ip}"
}
}
data "template_cloudinit_config" "nodes" {
gzip = false
base64_encode = false
part {
content_type = "text/cloud-config"
content = "${data.template_file.nodes.rendered}"
}
}