Skip to content

Commit 35fd0ca

Browse files
authored
Added compose for testing HA (#134)
1 parent 6d1f44d commit 35fd0ca

File tree

3 files changed

+98
-70
lines changed

3 files changed

+98
-70
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
services:
2+
core:
3+
image: ghcr.io/defguard/defguard:2.0.0-alpha2
4+
environment:
5+
DEFGUARD_COOKIE_INSECURE: "true"
6+
DEFGUARD_SECRET_KEY: defguard-secret-key-defguard-secret-key-defguard-secret-key-defguard-secret-key
7+
DEFGUARD_AUTH_SECRET: defguard-auth-secret
8+
DEFGUARD_GATEWAY_SECRET: defguard-gateway-secret
9+
DEFGUARD_YUBIBRIDGE_SECRET: defguard-yubibridge-secret
10+
DEFGUARD_DB_HOST: db
11+
DEFGUARD_DB_PORT: 5432
12+
DEFGUARD_DB_USER: defguard
13+
DEFGUARD_DB_PASSWORD: defguard
14+
DEFGUARD_DB_NAME: defguard
15+
DEFGUARD_ADOPT_EDGE: "edge1:50051"
16+
DEFGUARD_ADOPT_GATEWAY: "gateway1:50066"
17+
depends_on:
18+
- db
19+
- gateway-lb
20+
- edge-lb
21+
ports:
22+
- "8000:8000"
23+
24+
edge1:
25+
image: ghcr.io/defguard/defguard-proxy:2.0.0-alpha2
26+
volumes:
27+
- ./.volumes/certs2.0-ha/edge1:/etc/defguard/certs
28+
29+
edge2:
30+
image: ghcr.io/defguard/defguard-proxy:2.0.0-alpha2
31+
volumes:
32+
- ./.volumes/certs2.0-ha/edge2:/etc/defguard/certs
33+
34+
edge-lb:
35+
image: nginx:1.25-alpine
36+
depends_on:
37+
- edge1
38+
- edge2
39+
ports:
40+
- "8080:8080"
41+
volumes:
42+
- ./nginx/edge.conf:/etc/nginx/conf.d/default.conf:ro
43+
44+
gateway1:
45+
image: ghcr.io/defguard/gateway:2.0.0-alpha2
46+
cap_add:
47+
- NET_ADMIN
48+
volumes:
49+
- ./.volumes/certs2.0-ha/gateway1:/etc/defguard/certs
50+
environment:
51+
DEFGUARD_STATS_PERIOD: 10
52+
HEALTH_PORT: 55003
53+
54+
gateway2:
55+
image: ghcr.io/defguard/gateway:2.0.0-alpha2
56+
cap_add:
57+
- NET_ADMIN
58+
volumes:
59+
- ./.volumes/certs2.0-ha/gateway2:/etc/defguard/certs
60+
environment:
61+
DEFGUARD_STATS_PERIOD: 10
62+
HEALTH_PORT: 55003
63+
64+
gateway-lb:
65+
image: envoyproxy/envoy:v1.33-latest
66+
command: ["envoy", "-c", "/etc/envoy/envoy.yaml", "-l", "debug"]
67+
ports:
68+
- "51820:51820/udp"
69+
- "9901:9901"
70+
volumes:
71+
- ./envoy/envoy.yaml:/etc/envoy/envoy.yaml:ro
72+
depends_on:
73+
- gateway1
74+
- gateway2
75+
76+
db:
77+
image: postgres:18-alpine
78+
environment:
79+
POSTGRES_DB: defguard
80+
POSTGRES_USER: defguard
81+
POSTGRES_PASSWORD: defguard
82+
volumes:
83+
- ./.volumes/db2.0-ha:/var/lib/postgresql
Lines changed: 12 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
core:
3-
image: ghcr.io/defguard/defguard:2.0.0-alpha1
3+
image: ghcr.io/defguard/defguard:2.0.0-alpha2
44
environment:
55
DEFGUARD_COOKIE_INSECURE: "true"
66
DEFGUARD_SECRET_KEY: defguard-secret-key-defguard-secret-key-defguard-secret-key-defguard-secret-key
@@ -12,94 +12,39 @@ services:
1212
DEFGUARD_DB_USER: defguard
1313
DEFGUARD_DB_PASSWORD: defguard
1414
DEFGUARD_DB_NAME: defguard
15-
RUST_BACKTRACE: 1
15+
DEFGUARD_ADOPT_EDGE: "edge1:50051"
16+
DEFGUARD_ADOPT_GATEWAY: "gateway1:50066"
1617
depends_on:
1718
- db
19+
- gateway1
20+
- edge1
1821
ports:
1922
- "8000:8000"
2023

2124
edge1:
22-
image: ghcr.io/defguard/defguard-proxy:2.0.0-alpha1
25+
image: ghcr.io/defguard/defguard-proxy:2.0.0-alpha2
2326
volumes:
24-
- ./.volumes/certs2.0-ha/edge1:/etc/defguard/certs
25-
depends_on:
26-
- core
27-
28-
edge2:
29-
image: ghcr.io/defguard/defguard-proxy:2.0.0-alpha1
30-
volumes:
31-
- ./.volumes/certs2.0-ha/edge2:/etc/defguard/certs
32-
depends_on:
33-
- core
34-
35-
edge-lb:
36-
image: nginx:1.25-alpine
37-
depends_on:
38-
- edge1
39-
- edge2
27+
- ./.volumes/certs2.0/edge1:/etc/defguard/certs
4028
ports:
4129
- "8080:8080"
42-
volumes:
43-
- ./nginx/edge.conf:/etc/nginx/conf.d/default.conf:ro
4430

4531
gateway1:
46-
image: ghcr.io/defguard/gateway:2.0.0-alpha1
47-
depends_on:
48-
- core
32+
image: ghcr.io/defguard/gateway:2.0.0-alpha2
4933
cap_add:
5034
- NET_ADMIN
5135
volumes:
52-
- ./.volumes/certs2.0-ha/gateway1:/etc/defguard/certs
53-
environment:
54-
DEFGUARD_STATS_PERIOD: 10
55-
HEALTH_PORT: 55003
56-
57-
gateway2:
58-
image: ghcr.io/defguard/gateway:2.0.0-alpha1
59-
depends_on:
60-
- core
61-
cap_add:
62-
- NET_ADMIN
63-
volumes:
64-
- ./.volumes/certs2.0-ha/gateway2:/etc/defguard/certs
36+
- ./.volumes/certs2.0/gateway1:/etc/defguard/certs
37+
ports:
38+
- "51820:51820/udp"
6539
environment:
6640
DEFGUARD_STATS_PERIOD: 10
6741
HEALTH_PORT: 55003
6842

69-
gateway-lb:
70-
image: envoyproxy/envoy:v1.33-latest
71-
command: ["envoy", "-c", "/etc/envoy/envoy.yaml", "-l", "debug"]
72-
ports:
73-
- "50051:50051/udp"
74-
- "9901:9901"
75-
volumes:
76-
- ./envoy/envoy.yaml:/etc/envoy/envoy.yaml:ro
77-
depends_on:
78-
- gateway1
79-
- gateway2
80-
81-
# NGINX can be used for LB but not HA since it does not support healthchecks
82-
# gateway-lb-nginx:
83-
# image: nginx:1.25-alpine
84-
# command:
85-
# - /bin/sh
86-
# - -ec
87-
# - until getent hosts gateway1 gateway2 >/dev/null 2>&1; do sleep 0.2; done; exec nginx -g 'daemon off;'
88-
# ports:
89-
# - "50051:50051/udp"
90-
# volumes:
91-
# - ./nginx/gateway-lb.conf:/etc/nginx/nginx.conf:ro
92-
# depends_on:
93-
# - gateway1
94-
# - gateway2
95-
9643
db:
9744
image: postgres:18-alpine
9845
environment:
9946
POSTGRES_DB: defguard
10047
POSTGRES_USER: defguard
10148
POSTGRES_PASSWORD: defguard
10249
volumes:
103-
- ./.volumes/db2.0-ha:/var/lib/postgresql
104-
ports:
105-
- "5432:5432"
50+
- ./.volumes/db2.0:/var/lib/postgresql

docker-compose2.0/envoy/envoy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static_resources:
1010
address:
1111
socket_address:
1212
address: 0.0.0.0
13-
port_value: 50051
13+
port_value: 51820
1414
protocol: UDP
1515

1616
# UDP listeners use udp_listener_config + listener_filters (not filter_chains)
@@ -61,13 +61,13 @@ static_resources:
6161
address:
6262
socket_address:
6363
address: gateway1
64-
port_value: 50051
64+
port_value: 51820
6565
health_check_config:
6666
port_value: 55003
6767
- endpoint:
6868
address:
6969
socket_address:
7070
address: gateway2
71-
port_value: 50051
71+
port_value: 51820
7272
health_check_config:
7373
port_value: 55003

0 commit comments

Comments
 (0)