-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.yml
More file actions
166 lines (151 loc) · 4.28 KB
/
stack.yml
File metadata and controls
166 lines (151 loc) · 4.28 KB
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
networks:
fe-net: { external: true }
be-net: { external: true }
monitor-net: { external: true }
configs:
nginx-fe.conf:
file: ./proxy/nginx-fe.conf
haproxy.cfg:
file: ./haproxy/haproxy.cfg
prometheus.yml:
file: ./monitoring/prometheus.yml
volumes:
prometheus-data: {}
grafana-data: {}
services:
# ───────── Manager (DB + 모니터링) ─────────
mongodb:
image: mongo:8.0
networks: [be-net]
deploy:
placement:
constraints: ["node.hostname == manager"]
prometheus:
image: prom/prometheus:latest
ports: ["9090:9090"]
networks: [monitor-net]
configs:
- source: prometheus.yml
target: /etc/prometheus/prometheus.yml
mode: 0444
volumes:
- prometheus-data:/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.enable-lifecycle
deploy:
placement:
constraints: ["node.hostname == manager"]
grafana:
image: grafana/grafana:latest
ports: ["3001:3000"]
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- grafana-data:/var/lib/grafana
networks: [monitor-net]
deploy:
placement:
constraints: ["node.hostname == manager"]
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
privileged: true
ports: ["8080:8080"]
networks: [monitor-net]
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
deploy:
placement:
constraints: ["node.hostname == manager"]
# ───────── 프록시/프론트: 이동 가능(둘 중 살아있는 워커로 자동 이동) ─────────
proxy-fe:
image: nginx:1.25-alpine
ports: ["80:80"] # ingress 모드(기본), 어느 워커에 떠도 접근 가능
configs:
- source: nginx-fe.conf
target: /etc/nginx/nginx.conf
mode: 0444
networks: [fe-net]
deploy:
replicas: 1
placement:
constraints:
- "node.role == worker" # worker1/2 어디든 배치 허용 (← 핵심)
preferences:
- spread: "node.id"
frontend-1:
image: 192.168.0.208/demo/frontend:2.1
environment:
- PORT=8000
- GUESTBOOK_API_ADDR=http://haproxy:9000
networks: [fe-net]
deploy:
replicas: 1
placement:
constraints: ["node.role == worker"]
preferences: [{ spread: "node.id" }]
frontend-2:
image: 192.168.0.208/demo/frontend:2.1
environment:
- PORT=8000
- GUESTBOOK_API_ADDR=http://haproxy:9000
networks: [fe-net]
deploy:
replicas: 1
placement:
constraints: ["node.role == worker"]
preferences: [{ spread: "node.id" }]
frontend-3:
image: 192.168.0.208/demo/frontend:2.1
environment:
- PORT=8000
- GUESTBOOK_API_ADDR=http://haproxy:9000
networks: [fe-net]
deploy:
replicas: 1
placement:
constraints: ["node.role == worker"]
preferences: [{ spread: "node.id" }]
# ───────── Worker2 고정(그대로 유지): HAProxy + Backend×3 ─────────
haproxy:
image: haproxy:2.9-alpine
ports: ["9000:9000", "9001:8404"]
configs:
- source: haproxy.cfg
target: /usr/local/etc/haproxy/haproxy.cfg
mode: 0444
networks:
fe-net: { aliases: ["haproxy"] }
be-net: {}
deploy:
placement:
constraints: ["node.hostname == worker2"]
backend-1:
image: 192.168.0.208/demo/backend:2.0
environment: [ "PORT=8000", "GUESTBOOK_DB_ADDR=mongodb:27017" ]
networks: [be-net]
deploy:
replicas: 1
placement:
constraints: ["node.hostname == worker2"]
backend-2:
image: 192.168.0.208/demo/backend:2.0
environment: [ "PORT=8000", "GUESTBOOK_DB_ADDR=mongodb:27017" ]
networks: [be-net]
deploy:
replicas: 1
placement:
constraints: ["node.hostname == worker2"]
backend-3:
image: 192.168.0.208/demo/backend:2.0
environment: [ "PORT=8000", "GUESTBOOK_DB_ADDR=mongodb:27017" ]
networks: [be-net]
deploy:
replicas: 1
placement:
constraints: ["node.hostname == worker2"]