-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.etcd.yaml
More file actions
105 lines (96 loc) · 4.68 KB
/
docker-compose.etcd.yaml
File metadata and controls
105 lines (96 loc) · 4.68 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
# ═══════════════════════════════════════════════════════════════════
# Cluster ETCD para Patroni
# Autor: Eduardo Richard
# Versão: v2.0 (2025)
# ═══════════════════════════════════════════════════════════════════
# ═══════════════════════════════════════════════════════════════════
# ÂNCORAS YAML (Templates Reutilizáveis)
# ═══════════════════════════════════════════════════════════════════
x-etcd-common: &etcd-common
image: gcr.io/etcd-development/etcd:v3.5.17
networks:
- pg-ha-network
restart: unless-stopped
healthcheck:
test: ["CMD", "etcdctl", "endpoint", "health", "--endpoints=http://127.0.0.1:2379"]
interval: 10s
timeout: 5s
retries: 3
start_period: 15s
# --- RECURSOS DE CPU E MEMÓRIA ---
x-etcd-resources: &etcd-resources
deploy:
resources:
limits:
cpus: '0.10'
memory: 256M
# ═══════════════════════════════════════════════════════════════════
# SERVIÇOS
# ═══════════════════════════════════════════════════════════════════
services:
# --- ETCD Node 1 ---
etcd-1:
<<: [*etcd-common, *etcd-resources]
hostname: ${ETCD1_NAME}
container_name: ${ETCD1_NAME}
command:
- /usr/local/bin/etcd
- --name=${ETCD1_NAME}
- --data-dir=/etcd-data
- --listen-peer-urls=http://0.0.0.0:2380
- --listen-client-urls=http://0.0.0.0:2379
- --advertise-client-urls=http://${ETCD1_NAME}:2379
- --initial-advertise-peer-urls=http://${ETCD1_NAME}:2380
- --initial-cluster=${ETCD1_NAME}=http://${ETCD1_NAME}:2380,${ETCD2_NAME}=http://${ETCD2_NAME}:2380,${ETCD3_NAME}=http://${ETCD3_NAME}:2380
- --initial-cluster-token=patroni-etcd-cluster
- --initial-cluster-state=new
ports:
- "${ETCD1_HOST_PORT:-2379}:2379"
- "${ETCD1_PEER_PORT:-2380}:2380"
volumes:
- etcd-1-data:/etcd-data
# --- ETCD Node 2 ---
etcd-2:
<<: [*etcd-common, *etcd-resources]
hostname: ${ETCD2_NAME}
container_name: ${ETCD2_NAME}
command:
- /usr/local/bin/etcd
- --name=${ETCD2_NAME}
- --data-dir=/etcd-data
- --listen-peer-urls=http://0.0.0.0:2380
- --listen-client-urls=http://0.0.0.0:2379
- --advertise-client-urls=http://${ETCD2_NAME}:2379
- --initial-advertise-peer-urls=http://${ETCD2_NAME}:2380
- --initial-cluster=${ETCD1_NAME}=http://${ETCD1_NAME}:2380,${ETCD2_NAME}=http://${ETCD2_NAME}:2380,${ETCD3_NAME}=http://${ETCD3_NAME}:2380
- --initial-cluster-token=patroni-etcd-cluster
- --initial-cluster-state=new
ports:
- "${ETCD2_HOST_PORT:-2479}:2379"
- "${ETCD2_PEER_PORT:-2480}:2380"
volumes:
- etcd-2-data:/etcd-data
# --- ETCD Node 3 ---
etcd-3:
<<: [*etcd-common, *etcd-resources]
hostname: ${ETCD3_NAME}
container_name: ${ETCD3_NAME}
command:
- /usr/local/bin/etcd
- --name=${ETCD3_NAME}
- --data-dir=/etcd-data
- --listen-peer-urls=http://0.0.0.0:2380
- --listen-client-urls=http://0.0.0.0:2379
- --advertise-client-urls=http://${ETCD3_NAME}:2379
- --initial-advertise-peer-urls=http://${ETCD3_NAME}:2380
- --initial-cluster=${ETCD1_NAME}=http://${ETCD1_NAME}:2380,${ETCD2_NAME}=http://${ETCD2_NAME}:2380,${ETCD3_NAME}=http://${ETCD3_NAME}:2380
- --initial-cluster-token=patroni-etcd-cluster
- --initial-cluster-state=new
ports:
- "${ETCD3_HOST_PORT:-2579}:2379"
- "${ETCD3_PEER_PORT:-2580}:2380"
volumes:
- etcd-3-data:/etcd-data
# ═══════════════════════════════════════════════════════════════════
# NOTA: Volumes e Networks são gerenciados pelo docker-compose.yaml principal
# ═══════════════════════════════════════════════════════════════════