-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-db-hosts.tf
141 lines (125 loc) · 4.04 KB
/
app-db-hosts.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
# Экземпляры машин кластера Patroni
# Создаем порты отдельным ресурсом, так как параметр "fixed_ip_v4"
# для ресурсов "vkcs_compute_instance" корректно не работает
# Резервиуем адрес для виртуального IP кластера БД
resource "vkcs_networking_port" "vip-db" {
name = "Database cluster VIP"
network_id = vkcs_networking_network.dbcluster-net.id
description = "DO NOT CONNECT ANYWHERE!!!"
admin_state_up = false
fixed_ip {
subnet_id = vkcs_networking_subnet.dbcluster-subnet.id
ip_address = "172.16.50.123"
}
}
# Разрешаем виртуальный IP на портах серверов БД
resource "vkcs_networking_port" "zone1-db-port" {
name = "zone1 Database Port"
network_id = vkcs_networking_network.dbcluster-net.id
description = "zone1 Database port"
fixed_ip {
subnet_id = vkcs_networking_subnet.dbcluster-subnet.id
ip_address = "172.16.50.100"
}
allowed_address_pairs {
ip_address = "172.16.50.123"
}
security_group_ids = [vkcs_networking_secgroup.interconnect.id]
}
resource "vkcs_networking_port" "zone2-db-port" {
name = "zone2 Database Port"
network_id = vkcs_networking_network.dbcluster-net.id
description = "zone2 Database port"
fixed_ip {
subnet_id = vkcs_networking_subnet.dbcluster-subnet.id
ip_address = "172.16.50.101"
}
allowed_address_pairs {
ip_address = "172.16.50.123"
}
security_group_ids = [vkcs_networking_secgroup.interconnect.id]
}
resource "vkcs_networking_port" "zone3-db-port" {
name = "zone3 Database Port"
network_id = vkcs_networking_network.dbcluster-net.id
description = "zone3 Database port"
fixed_ip {
subnet_id = vkcs_networking_subnet.dbcluster-subnet.id
ip_address = "172.16.50.102"
}
allowed_address_pairs {
ip_address = "172.16.50.123"
}
security_group_ids = [vkcs_networking_secgroup.interconnect.id]
}
resource "vkcs_compute_instance" "zone1-db" {
name = "zone1-db"
flavor_name = var.db_flavor
availability_zone = var.zones["zone1"]
key_pair = var.key_pair_name
tags = ["reference_arch"]
metadata = {
sid = "reference_arch"
}
block_device {
source_type = "image"
destination_type = "volume"
volume_type = "ceph-ssd"
uuid = data.vkcs_images_image.ubuntu.id
volume_size = 35
boot_index = 0
delete_on_termination = true
}
config_drive = true
network {
port = vkcs_networking_port.zone1-db-port.id
}
}
resource "vkcs_compute_instance" "zone2-db" {
name = "zone2-db"
flavor_name = var.db_flavor
availability_zone = var.zones["zone2"]
security_group_ids = [vkcs_networking_secgroup.interconnect.id]
key_pair = var.key_pair_name
tags = ["reference_arch"]
metadata = {
sid = "reference_arch"
}
block_device {
source_type = "image"
destination_type = "volume"
volume_type = "ceph-ssd"
uuid = data.vkcs_images_image.ubuntu.id
volume_size = 35
boot_index = 0
delete_on_termination = true
}
config_drive = true
network {
port = vkcs_networking_port.zone2-db-port.id
}
}
resource "vkcs_compute_instance" "zone3-db" {
name = "zone3-db"
flavor_name = var.db_flavor
availability_zone = var.zones["zone3"]
security_group_ids = [vkcs_networking_secgroup.interconnect.id]
key_pair = var.key_pair_name
tags = ["reference_arch"]
metadata = {
sid = "reference_arch"
}
block_device {
source_type = "image"
destination_type = "volume"
volume_type = "ceph-ssd"
uuid = data.vkcs_images_image.ubuntu.id
volume_size = 35
boot_index = 0
delete_on_termination = true
}
config_drive = true
network {
port = vkcs_networking_port.zone3-db-port.id
}
}