Skip to content

Commit 8cfbcbf

Browse files
committed
akeyless-pg-bridge: in-cluster WireGuard endpoint to reach paperless-pg
Dials out to bpi-r4 wg_csm (10.99.0.2, zero cluster exposure) and socat-forwards :5432 -> paperless-pg-rw, so the existing CM-VM Akeyless gateway can mint dynamic Postgres creds over the tunnel without exposing the database. Keys via ESO from Akeyless /mdapi/wireguard/csm-bridge/*.
1 parent 7efdd3d commit 8cfbcbf

3 files changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# In-cluster end of the DMZ<->cluster WireGuard bridge.
2+
# - wireguard container: dials OUT to bpi-r4 wg_csm (zero cluster exposure), tunnel IP 10.99.0.2
3+
# - socat sidecar: forwards tunnel :5432 -> paperless-pg-rw (the CNPG primary)
4+
# The CM-VM gateway reaches 10.99.0.2:5432 via its default route -> bpi-r4 -> wg_csm.
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: akeyless-pg-bridge
9+
namespace: akeyless-pg-bridge
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
app: akeyless-pg-bridge
15+
template:
16+
metadata:
17+
labels:
18+
app: akeyless-pg-bridge
19+
spec:
20+
initContainers:
21+
- name: config
22+
image: busybox
23+
command:
24+
- sh
25+
- -c
26+
- |
27+
mkdir -p /config/wg_confs
28+
cat > /config/wg_confs/wg0.conf << EOF
29+
[Interface]
30+
Address = 10.99.0.2/32
31+
PrivateKey = $(cat /secrets/private-key)
32+
33+
[Peer]
34+
PublicKey = lxw2utAc7/th3rLtm7Ga+78U9iSZBzbLT53j9bY1D00=
35+
PresharedKey = $(cat /secrets/psk)
36+
Endpoint = 192.168.1.254:51822
37+
AllowedIPs = 10.99.0.1/32
38+
PersistentKeepalive = 25
39+
EOF
40+
volumeMounts:
41+
- { name: config, mountPath: /config }
42+
- { name: secrets, mountPath: /secrets }
43+
containers:
44+
- name: wireguard
45+
image: lscr.io/linuxserver/wireguard:latest
46+
securityContext:
47+
capabilities:
48+
add: [NET_ADMIN]
49+
env:
50+
- { name: PUID, value: "1000" }
51+
- { name: PGID, value: "1000" }
52+
volumeMounts:
53+
- { name: config, mountPath: /config }
54+
resources:
55+
requests: { cpu: 10m, memory: 32Mi }
56+
limits: { cpu: 200m, memory: 64Mi }
57+
- name: proxy
58+
image: alpine/socat
59+
command:
60+
- sh
61+
- -c
62+
- socat TCP4-LISTEN:5432,fork,reuseaddr TCP4:paperless-pg-rw.paperless.svc.cluster.local:5432
63+
resources:
64+
requests: { cpu: 5m, memory: 16Mi }
65+
limits: { cpu: 100m, memory: 32Mi }
66+
volumes:
67+
- { name: config, emptyDir: {} }
68+
- name: secrets
69+
secret:
70+
secretName: wg-csm-bridge

akeyless-pg-bridge/bridge-es.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# WireGuard key material for the DMZ<->cluster bridge, delivered from Akeyless.
2+
# Lets the EXISTING CM-VM Akeyless gateway reach in-cluster paperless-pg via the
3+
# tunnel, so dynamic-secret producers work without exposing Postgres.
4+
apiVersion: external-secrets.io/v1
5+
kind: ExternalSecret
6+
metadata:
7+
name: wg-csm-bridge
8+
namespace: akeyless-pg-bridge
9+
spec:
10+
refreshInterval: 1h
11+
secretStoreRef:
12+
kind: ClusterSecretStore
13+
name: cm-akeyless
14+
target:
15+
name: wg-csm-bridge
16+
creationPolicy: Owner
17+
data:
18+
- remoteRef:
19+
key: /mdapi/wireguard/csm-bridge/pod-private-key
20+
secretKey: private-key
21+
- remoteRef:
22+
key: /mdapi/wireguard/csm-bridge/psk
23+
secretKey: psk

akeyless-pg-bridge/fleet.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
defaultNamespace: akeyless-pg-bridge
2+
namespaceLabels:
3+
cd.mdapi.ch: fleet
4+
cdenv.mdapi.ch: prod

0 commit comments

Comments
 (0)