-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnode.tf
90 lines (76 loc) · 2.57 KB
/
node.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
resource "random_id" "node_image_name" {
byte_length = 8
}
resource "outscale_image" "node" {
image_name = "${var.cluster_name}-${random_id.node_image_name.hex}"
vm_id = outscale_vm.bastion.vm_id
no_reboot = "true"
depends_on = [shell_script.bastion-playbook]
}
resource "outscale_subnet" "nodes" {
count = var.public_cloud ? 0 : 1
net_id = outscale_net.net[0].net_id
ip_range = "10.0.1.0/24"
subregion_name = "${var.region}a"
}
resource "outscale_route_table" "nodes" {
count = var.public_cloud ? 0 : 1
net_id = outscale_net.net[0].net_id
}
resource "outscale_route" "node-default" {
count = var.public_cloud ? 0 : 1
destination_ip_range = "0.0.0.0/0"
nat_service_id = outscale_nat_service.nat[0].nat_service_id
route_table_id = outscale_route_table.nodes[0].route_table_id
}
resource "outscale_route" "node-pods" {
count = var.public_cloud ? 0 : var.worker_count
destination_ip_range = "10.42.${count.index}.0/24"
vm_id = outscale_vm.workers[count.index].vm_id
route_table_id = outscale_route_table.nodes[0].route_table_id
}
resource "outscale_route" "node-services" {
count = var.public_cloud ? 0 : var.worker_count
destination_ip_range = "10.43.${count.index}.0/24"
vm_id = outscale_vm.workers[count.index].vm_id
route_table_id = outscale_route_table.nodes[0].route_table_id
}
resource "outscale_route_table_link" "nodes" {
count = var.public_cloud ? 0 : 1
subnet_id = outscale_subnet.nodes[0].subnet_id
route_table_id = outscale_route_table.nodes[0].route_table_id
}
resource "outscale_security_group" "node" {
description = "Kubernetes node (${var.cluster_name})"
net_id = var.public_cloud ? null : outscale_net.net[0].net_id
tags {
key = "OscK8sClusterID/${var.cluster_name}"
value = "owned"
}
tags {
key = "OscK8sMainSG/${var.cluster_name}"
value = "True"
}
}
resource "outscale_security_group_rule" "node" {
flow = "Inbound"
security_group_id = outscale_security_group.node.id
# Authorize node port between nodes
rules {
from_port_range = "30000"
to_port_range = "32767"
ip_protocol = "tcp"
security_groups_members {
security_group_id = outscale_security_group.node.id
}
}
# Authorize node port from bastion to nodes
rules {
from_port_range = "30000"
to_port_range = "32767"
ip_protocol = "tcp"
security_groups_members {
security_group_id = outscale_security_group.bastion.id
}
}
}