-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.tf
102 lines (86 loc) · 2.86 KB
/
master.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
resource "aws_autoscaling_group" "master" {
# vpc_zone_identifier = ["${aws_subnet.k8-master-subnet.id}"]
availability_zones = ["${split(",", var.availability_zones)}"]
name = "k8-master-asg-${var.cluster_name}"
max_size = 3
min_size = "${var.master_node_count}"
health_check_grace_period = 300
health_check_type = "EC2"
desired_capacity = "${var.master_node_count}"
force_delete = false
launch_configuration = "${aws_launch_configuration.master.name}"
load_balancers = ["${aws_elb.master-elb.name}"]
tag {
key = "Name"
value = "master-${var.cluster_name}"
propagate_at_launch = "true"
}
tag {
key = "apptype"
value = "k8-master"
propagate_at_launch = "true"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_launch_configuration" "master" {
name = "k8-master-lc-${var.cluster_name}"
image_id = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "${var.master_ins_type}"
key_name = "${var.key_name}"
security_groups = ["${aws_security_group.default_kube.id}"]
# user_data = "${file("${path.module}/files/master-userdata.yml")}"
user_data = "${template_file.master-user-data.rendered}"
iam_instance_profile = "${aws_iam_instance_profile.master.id}"
lifecycle {
create_before_destroy = true
}
}
#master loadbalancer
resource "aws_elb" "master-elb" {
name = "k8-master-elb-${var.cluster_name}"
# subnets = ["${aws_subnet.k8-etcd-subnet-zone01.id}","${aws_subnet.k8-etcd-subnet-zone02.id}"]
# The same availability zone as our instances
availability_zones = ["${split(",", var.availability_zones)}"]
security_groups = ["${aws_security_group.elb_sg.id}"]
idle_timeout = "${var.idle_timeout}"
internal = "false"
listener {
instance_port = 8080
instance_protocol = "http"
lb_port = 8080
lb_protocol = "http"
}
listener {
instance_port = 443
instance_protocol = "tcp"
lb_port = 443
lb_protocol = "tcp"
}
listener {
instance_port = 10249
instance_protocol = "tcp"
lb_port = 10249
lb_protocol = "tcp"
}
listener {
instance_port = 10251
instance_protocol = "tcp"
lb_port = 10251
lb_protocol = "tcp"
}
listener {
instance_port = 10252
instance_protocol = "tcp"
lb_port = 10252
lb_protocol = "tcp"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "TCP:443"
interval = 30
}
}