-
-
Notifications
You must be signed in to change notification settings - Fork 174
/
Copy path06-nodes.tf
138 lines (119 loc) · 4.03 KB
/
06-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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Create an SSH keypair
resource "aws_key_pair" "keypair" {
key_name = "${var.key_name}"
public_key = "${file(var.public_key_path)}"
}
// Create the master userdata script.
data "template_file" "setup-master" {
template = "${file("${path.module}/files/setup-master.sh")}"
vars {
availability_zone = "${lookup(var.subnetaz, var.region)}"
}
}
// Launch configuration for the consul cluster auto-scaling group.
resource "aws_instance" "master" {
ami = "${data.aws_ami.rhel7_2.id}"
# Master nodes require at least 16GB of memory.
instance_type = "m4.xlarge"
subnet_id = "${aws_subnet.public-subnet.id}"
iam_instance_profile = "${aws_iam_instance_profile.openshift-instance-profile.id}"
user_data = "${data.template_file.setup-master.rendered}"
security_groups = [
"${aws_security_group.openshift-vpc.id}",
"${aws_security_group.openshift-public-ingress.id}",
"${aws_security_group.openshift-public-egress.id}",
]
// We need at least 30GB for OpenShift, let's be greedy...
root_block_device {
volume_size = 50
volume_type = "gp2"
}
# Storage for Docker, see:
# https://docs.openshift.org/latest/install_config/install/host_preparation.html#configuring-docker-storage
ebs_block_device {
device_name = "/dev/sdf"
volume_size = 80
volume_type = "gp2"
}
key_name = "${aws_key_pair.keypair.key_name}"
// Use our common tags and add a specific name.
tags = "${merge(
local.common_tags,
map(
"Name", "OpenShift Master"
)
)}"
}
// Create the node userdata script.
data "template_file" "setup-node" {
template = "${file("${path.module}/files/setup-node.sh")}"
vars {
availability_zone = "${lookup(var.subnetaz, var.region)}"
}
}
// Create the two nodes. This would be better as a Launch Configuration and
// autoscaling group, but I'm keeping it simple...
resource "aws_instance" "node1" {
ami = "${data.aws_ami.rhel7_2.id}"
instance_type = "${var.amisize}"
subnet_id = "${aws_subnet.public-subnet.id}"
iam_instance_profile = "${aws_iam_instance_profile.openshift-instance-profile.id}"
user_data = "${data.template_file.setup-node.rendered}"
security_groups = [
"${aws_security_group.openshift-vpc.id}",
"${aws_security_group.openshift-public-ingress.id}",
"${aws_security_group.openshift-public-egress.id}",
]
// We need at least 30GB for OpenShift, let's be greedy...
root_block_device {
volume_size = 50
volume_type = "gp2"
}
# Storage for Docker, see:
# https://docs.openshift.org/latest/install_config/install/host_preparation.html#configuring-docker-storage
ebs_block_device {
device_name = "/dev/sdf"
volume_size = 80
volume_type = "gp2"
}
key_name = "${aws_key_pair.keypair.key_name}"
// Use our common tags and add a specific name.
tags = "${merge(
local.common_tags,
map(
"Name", "OpenShift Node 1"
)
)}"
}
resource "aws_instance" "node2" {
ami = "${data.aws_ami.rhel7_2.id}"
instance_type = "${var.amisize}"
subnet_id = "${aws_subnet.public-subnet.id}"
iam_instance_profile = "${aws_iam_instance_profile.openshift-instance-profile.id}"
user_data = "${data.template_file.setup-node.rendered}"
security_groups = [
"${aws_security_group.openshift-vpc.id}",
"${aws_security_group.openshift-public-ingress.id}",
"${aws_security_group.openshift-public-egress.id}",
]
// We need at least 30GB for OpenShift, let's be greedy...
root_block_device {
volume_size = 50
volume_type = "gp2"
}
# Storage for Docker, see:
# https://docs.openshift.org/latest/install_config/install/host_preparation.html#configuring-docker-storage
ebs_block_device {
device_name = "/dev/sdf"
volume_size = 80
volume_type = "gp2"
}
key_name = "${aws_key_pair.keypair.key_name}"
// Use our common tags and add a specific name.
tags = "${merge(
local.common_tags,
map(
"Name", "OpenShift Node 2"
)
)}"
}