-
Notifications
You must be signed in to change notification settings - Fork 138
/
deployment.yaml
239 lines (232 loc) · 7.59 KB
/
deployment.yaml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# ***************** Universidad de los Andes ***********************
# ****** Departamento de Ingeniería de Sistemas y Computación ******
# ********** Arquitectura y diseño de Software - ISIS2503 **********
#
# Infraestructura para laboratorio de microservicios con Django
# Elementos a desplegar:
# 1. Firewalls:
# - msd-api-gateway
# - msd-services-apps
# - msd-services-apps-web
# - msd-service-db
# 2. Instancias MVs:
# - msd-kong-instance
# - msd-variables-db (postgreSQL instalado y configurado)
# - msd-measurements-db (postgreSQL instalado y configurado)
# - msd-variables-ms (Servicio de variables descargado)
# - msd-measurements-ms (Servicio de measurements instalado y configurado)
resources:
# Firewall rules
- name: msd-api-gateway
type: compute.v1.firewall
properties:
network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
priority: 1000
direction: INGRESS
sourceRanges:
- 0.0.0.0/0
targetTags:
- msd-api-gateway
allowed:
- IPProtocol: TCP
ports:
- 8000
- name: msd-services-apps
type: compute.v1.firewall
properties:
network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
priority: 1000
direction: INGRESS
sourceTags:
- msd-api-gateway
targetTags:
- msd-services-firewall
allowed:
- IPProtocol: TCP
ports:
- 8080
- name: msd-services-apps-web
type: compute.v1.firewall
properties:
network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
priority: 1000
direction: INGRESS
sourceRanges:
- 0.0.0.0/0
targetTags:
- msd-services-firewall
allowed:
- IPProtocol: TCP
ports:
- 8080
- name: msd-service-db
type: compute.v1.firewall
properties:
network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
priority: 1000
direction: INGRESS
sourceTags:
- msd-services-firewall
targetTags:
- msd-service-db
allowed:
- IPProtocol: TCP
ports:
- 5432
# Kong instance
- name: msd-kong-instance
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/zones/us-central1-a/machineTypes/e2-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-101-17162-463-8
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
networkIP: 10.128.0.81
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
tags:
items:
- msd-api-gateway
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
sudo mkdir /home/labs
cd /home/labs
sudo git clone https://github.com/ISIS2503/ISIS2503-Microservices-AppDjango.git
cd ISIS2503-Microservices-AppDjango
docker network create kong-net
docker run -d --name kong --network=kong-net --restart=always \
-v "$(pwd):/kong/declarative/" -e "KONG_DATABASE=off" \
-e "KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yaml" \
-p 8000:8000 kong/kong-gateway
# Database instances
- name: msd-variables-db
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/zones/us-central1-a/machineTypes/e2-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-101-17162-463-8
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
networkIP: 10.128.0.82
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
tags:
items:
- msd-service-db
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
docker run --restart=always -d -e POSTGRES_USER=variables_user -e POSTGRES_DB=variables_db -e POSTGRES_PASSWORD=isis2503 -p 5432:5432 --name variables-db postgres
- name: msd-measurements-db
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/zones/us-central1-a/machineTypes/e2-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-101-17162-463-8
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
networkIP: 10.128.0.83
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
tags:
items:
- msd-service-db
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
docker run --restart=always -d -e POSTGRES_USER=measurements_user -e POSTGRES_DB=measurements_db -e POSTGRES_PASSWORD=isis2503 -p 5432:5432 --name measurements-db postgres
# Service instances
- name: msd-variables-ms
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/zones/us-central1-a/machineTypes/e2-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images/cos-101-17162-463-8
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
networkIP: 10.128.0.84
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
tags:
items:
- msd-services-firewall
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
sudo mkdir /home/labs
cd /home/labs
sudo git clone https://github.com/ISIS2503/ISIS2503-Microservices-AppDjango.git
cd ISIS2503-Microservices-AppDjango/variables
- name: msd-measurements-ms
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/zones/us-central1-a/machineTypes/e2-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20240307b
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/<id-proyecto>/global/networks/default
networkIP: 10.128.0.85
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
tags:
items:
- msd-services-firewall
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
sudo apt-get update
sudo apt install python3-pip -y
sudo mkdir /home/labs
cd /home/labs
sudo git clone https://github.com/ISIS2503/ISIS2503-Microservices-AppDjango.git
cd ISIS2503-Microservices-AppDjango/measurements
sudo pip3 install -r requirements.txt
sudo python3 manage.py makemigrations
sudo python3 manage.py migrate