-
Notifications
You must be signed in to change notification settings - Fork 1
/
terraform-network.tf
154 lines (137 loc) · 4.92 KB
/
terraform-network.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
resource "openstack_networking_network_v2" "clusternetwork" {
name = "k8s-cluster"
admin_state_up = "true"
}
resource "openstack_networking_subnet_v2" "k8s-cluster" {
network_id = "${openstack_networking_network_v2.clusternetwork.id}"
cidr = "10.0.0.0/24"
no_gateway = true
}
resource "openstack_networking_secgroup_v2" "sec_egress" {
name = "Egress"
description = "Security Group for egress traffic"
delete_default_rules = false
}
resource "openstack_networking_secgroup_v2" "sec_ssh" {
name = "SSH"
description = "Security Group for SSH"
delete_default_rules = true
}
resource "openstack_networking_secgroup_rule_v2" "sec_ssh_rule_1" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 22
port_range_max = 22
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.sec_ssh.id}"
}
resource "openstack_networking_secgroup_v2" "sec_master" {
name = "K8S Master"
description = "Security Group for K8S Master Nodes"
delete_default_rules = true
}
resource "openstack_networking_secgroup_rule_v2" "sec_master_rule_1" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 6443
port_range_max = 6443
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.sec_master.id}"
}
resource "openstack_networking_secgroup_v2" "sec_node" {
name = "K8S Nodes"
description = "Security Group for K8S Nodes"
delete_default_rules = true
}
resource "openstack_networking_secgroup_rule_v2" "sec_nodes_rule_1" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 4149
port_range_max = 4149
remote_ip_prefix = "${openstack_networking_subnet_v2.k8s-cluster.cidr}"
security_group_id = "${openstack_networking_secgroup_v2.sec_node.id}"
description = "kublet"
}
resource "openstack_networking_secgroup_rule_v2" "sec_nodes_rule_2" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 10250
port_range_max = 10250
remote_ip_prefix = "${openstack_networking_subnet_v2.k8s-cluster.cidr}"
security_group_id = "${openstack_networking_secgroup_v2.sec_node.id}"
description = "kublet"
}
resource "openstack_networking_secgroup_rule_v2" "sec_nodes_rule_3" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 10255
port_range_max = 10256
remote_ip_prefix = "${openstack_networking_subnet_v2.k8s-cluster.cidr}"
security_group_id = "${openstack_networking_secgroup_v2.sec_node.id}"
description = "kublet and kube-proxy"
}
resource "openstack_networking_secgroup_rule_v2" "sec_nodes_rule_4" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 6783
port_range_max = 6783
remote_ip_prefix = "${openstack_networking_subnet_v2.k8s-cluster.cidr}"
security_group_id = "${openstack_networking_secgroup_v2.sec_node.id}"
description = "CNI Weave Control Port"
}
resource "openstack_networking_secgroup_rule_v2" "sec_nodes_rule_5" {
direction = "ingress"
ethertype = "IPv4"
protocol = "udp"
port_range_min = 6783
port_range_max = 6784
remote_ip_prefix = "${openstack_networking_subnet_v2.k8s-cluster.cidr}"
security_group_id = "${openstack_networking_secgroup_v2.sec_node.id}"
description = "CNI Weave Data Ports"
}
resource "openstack_networking_secgroup_v2" "sec_etcd" {
name = "Etcd"
description = "Security Group for etcd nodes"
delete_default_rules = true
}
resource "openstack_networking_secgroup_rule_v2" "sec_etcd_rule_1" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 2379
port_range_max = 2380
remote_ip_prefix = "${openstack_networking_subnet_v2.k8s-cluster.cidr}"
security_group_id = "${openstack_networking_secgroup_v2.sec_etcd.id}"
description = "etcd cluster port"
}
resource "openstack_networking_secgroup_v2" "sec_http" {
name = "HTTP"
description = "Security Group for http traffic"
delete_default_rules = true
}
resource "openstack_networking_secgroup_rule_v2" "sec_http_rule_1" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 80
port_range_max = 80
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.sec_http.id}"
description = "http"
}
resource "openstack_networking_secgroup_rule_v2" "sec_http_rule_2" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 443
port_range_max = 443
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.sec_http.id}"
description = "https"
}