Skip to content

Commit 60a766b

Browse files
committed
feat: add Envoy proxy support
1 parent 4f5e290 commit 60a766b

19 files changed

+585
-6
lines changed

ansible/files/adminapi.sudoers.conf

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Cmnd_Alias ENVOY = /bin/systemctl start envoy.service, /bin/systemctl stop envoy.service, /bin/systemctl restart envoy.service, /bin/systemctl disable envoy.service, /bin/systemctl enable envoy.service, /bin/systemctl reload envoy.service
12
Cmnd_Alias KONG = /bin/systemctl start kong.service, /bin/systemctl stop kong.service, /bin/systemctl restart kong.service, /bin/systemctl disable kong.service, /bin/systemctl enable kong.service, /bin/systemctl reload kong.service
23
Cmnd_Alias POSTGREST = /bin/systemctl start postgrest.service, /bin/systemctl stop postgrest.service, /bin/systemctl restart postgrest.service, /bin/systemctl disable postgrest.service, /bin/systemctl enable postgrest.service
34
Cmnd_Alias GOTRUE = /bin/systemctl start gotrue.service, /bin/systemctl stop gotrue.service, /bin/systemctl restart gotrue.service, /bin/systemctl disable gotrue.service, /bin/systemctl enable gotrue.service

ansible/files/envoy.service

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[Unit]
2+
Description=Envoy
3+
After=postgrest.service gotrue.service adminapi.service
4+
Wants=postgrest.service gotrue.service adminapi.service
5+
Conflicts=kong.service
6+
7+
[Service]
8+
Type=simple
9+
10+
# Need to run via a restarter script to support hot restart when using a process
11+
# manager, see:
12+
# https://www.envoyproxy.io/docs/envoy/latest/operations/hot_restarter
13+
ExecStart=/opt/envoy-hot-restarter.py /opt/start-envoy.sh
14+
15+
ExecReload=/bin/kill -HUP $MAINPID
16+
ExecStop=/bin/kill -TERM $MAINPID
17+
User=envoy
18+
Slice=services.slice
19+
Restart=always
20+
RestartSec=3
21+
LimitNOFILE=100000
22+
23+
# The envoy user is unpriviledged and thus not permited to bind on ports < 1024
24+
# Via systemd we grant the process a set of priviledges to bind to 80/443
25+
# See http://archive.vn/36zJU
26+
AmbientCapabilities=CAP_NET_BIND_SERVICE
27+
28+
[Install]
29+
WantedBy=multi-user.target
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function envoy_on_request(request_handle)
2+
local authorization = request_handle:headers():get("authorization")
3+
4+
if authorization and authorization:find("^[Bb][Aa][Ss][Ii][Cc] " .. request_handle:metadata():get("credentials")) then
5+
return
6+
end
7+
8+
request_handle:respond({
9+
[":status"] = "401",
10+
["WWW-Authenticate"] = "Basic realm=\"Unknown\""
11+
}, "Unauthorized")
12+
end

ansible/files/envoy_config/cds.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
resources:
2+
- '@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
3+
name: admin_api
4+
load_assignment:
5+
cluster_name: admin_api
6+
endpoints:
7+
- lb_endpoints:
8+
- endpoint:
9+
address:
10+
socket_address:
11+
address: 127.0.0.1
12+
port_value: 8085
13+
transport_socket:
14+
name: envoy.transport_sockets.tls
15+
typed_config:
16+
'@type': >-
17+
type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
18+
- '@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
19+
name: gotrue
20+
load_assignment:
21+
cluster_name: gotrue
22+
endpoints:
23+
- lb_endpoints:
24+
- endpoint:
25+
address:
26+
socket_address:
27+
address: 127.0.0.1
28+
port_value: 9999
29+
- '@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
30+
name: postgrest
31+
load_assignment:
32+
cluster_name: postgrest
33+
endpoints:
34+
- lb_endpoints:
35+
- endpoint:
36+
address:
37+
socket_address:
38+
address: 127.0.0.1
39+
port_value: 3000
40+
- '@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
41+
name: postgrest_admin
42+
load_assignment:
43+
cluster_name: postgrest_admin
44+
endpoints:
45+
- lb_endpoints:
46+
- endpoint:
47+
address:
48+
socket_address:
49+
address: 127.0.0.1
50+
port_value: 3001
51+

ansible/files/envoy_config/envoy.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
dynamic_resources:
2+
cds_config:
3+
path_config_source:
4+
path: /etc/envoy/cds.yaml
5+
resource_api_version: V3
6+
lds_config:
7+
path_config_source:
8+
path: /etc/envoy/lds.yaml
9+
resource_api_version: V3
10+
node:
11+
cluster: cluster_0
12+
id: node_0
13+
overload_manager:
14+
resource_monitors:
15+
- name: envoy.resource_monitors.global_downstream_max_connections
16+
typed_config:
17+
'@type': >-
18+
type.googleapis.com/envoy.extensions.resource_monitors.downstream_connections.v3.DownstreamConnectionsConfig
19+
max_active_downstream_connections: 30000
20+
stats_config:
21+
stats_matcher:
22+
reject_all: true
23+

0 commit comments

Comments
 (0)