Skip to content

Commit 26ccf6c

Browse files
authored
Merge pull request #6 from tjann7/lab07
Lab07 SD-02 Timur Suleymanov
2 parents 2717bbb + 55f7232 commit 26ccf6c

File tree

9 files changed

+89
-4
lines changed

9 files changed

+89
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,6 @@ cython_debug/
174174
.pypirc
175175
terraform/yandex_cloud/key.json
176176
terraform/yandex_cloud/terraform.rc
177+
ansible/roles/web_app/vars/main.yml
178+
ansible/ansible.builtin.env
179+
terraform/yandex_cloud/authorized_key.json

ansible/roles/web_app/templates/docker-compose.yml.j2

Whitespace-only changes.

app_go/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ USER $ADMIN_USER
1616
RUN go build -o randomizer main.go
1717

1818
# Explicitly specify port
19-
EXPOSE 3000
19+
EXPOSE 5500
2020

2121
CMD ["./randomizer"]

app_go/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
var tpl = template.Must(template.ParseFiles("static/index.html"))
1010

11-
const PORT = "3000"
11+
const PORT = "5500"
1212

1313
func indexHandler(w http.ResponseWriter, r *http.Request) {
1414
// Handler calls template to show index.html

app_go/randomizer

10.2 MB
Binary file not shown.

app_python/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ RUN adduser --system $ADMIN_USER
1717
USER $ADMIN_USER
1818

1919
# Explicitly specify port
20-
EXPOSE 5000
20+
EXPOSE 5005
2121

2222
CMD ["python", "moscow_app.py"]

app_python/moscow_app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
app = Flask(__name__)
99
MOSCOW = timezone(timedelta(hours=3), "Moscow")
10+
HOST = "0.0.0.0"
11+
PORT = 5005
1012

1113
@app.route("/")
1214
def index():
@@ -21,4 +23,4 @@ def index():
2123

2224

2325
if __name__ == "__main__":
24-
app.run()
26+
app.run(HOST, PORT)

monitoring/docker-compose.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: "3.3"
2+
3+
networks:
4+
loki:
5+
6+
services:
7+
loki:
8+
image: grafana/loki:latest
9+
ports:
10+
- "3100:3100"
11+
command: -config.file=/etc/loki/local-config.yaml
12+
networks:
13+
- loki
14+
15+
promtail:
16+
image: grafana/promtail:latest
17+
volumes:
18+
- /var/log:/var/log
19+
- /var/run/docker.sock:/var/run/docker.sock
20+
- /var/lib/docker/containers:/var/lib/docker/containers
21+
- ./promtail.yml:/etc/promtail/config.yml
22+
command: -config.file=/etc/promtail/config.yml
23+
networks:
24+
- loki
25+
26+
grafana:
27+
environment:
28+
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
29+
- GF_AUTH_ANONYMOUS_ENABLED=true
30+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
31+
- GF_FEATURE_TOGGLES_ENABLE=alertingSimplifiedRouting,alertingQueryAndExpressionsStepMode
32+
entrypoint:
33+
- sh
34+
- -euc
35+
- |
36+
mkdir -p /etc/grafana/provisioning/datasources
37+
cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
38+
apiVersion: 1
39+
datasources:
40+
- name: Loki
41+
type: loki
42+
access: proxy
43+
orgId: 1
44+
url: http://loki:3100
45+
basicAuth: false
46+
isDefault: true
47+
version: 1
48+
editable: false
49+
EOF
50+
/run.sh
51+
image: grafana/grafana:latest
52+
ports:
53+
- "3000:3000"
54+
networks:
55+
- loki
56+
moscow_time:
57+
image: tjann7/moscow_time:latest
58+
ports:
59+
- "5005:5005"
60+
logging:
61+
driver: "json-file"
62+
go_random:
63+
image: tjann7/go_random:latest
64+
ports:
65+
- "5500:5500"

monitoring/promtail.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server:
2+
http_listen_port: 9080
3+
grpc_listen_port: 0
4+
positions:
5+
filename: /tmp/positions.yaml
6+
client:
7+
url: http://loki:3100/api/v1/push
8+
scrape_configs:
9+
- job_name: logging_both_dockersW
10+
static_configs:
11+
- targets:
12+
- localhost
13+
labels:
14+
job: docker
15+
__path__: /var/lib/docker/containers/*/*log # For linux only

0 commit comments

Comments
 (0)