Skip to content

Commit de1f717

Browse files
committed
refactor(wireguard): use raw static config
I want to set up a mesh with multiple sites, so I need static peer configurations instead of those generated by the WireGuard container.
1 parent 8d4f52c commit de1f717

File tree

5 files changed

+58
-11
lines changed

5 files changed

+58
-11
lines changed

Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ post-install:
2929
# TODO maybe there's a better way to manage backup with GitOps?
3030
backup:
3131
./scripts/backup --action setup --namespace=actualbudget --pvc=actualbudget-data
32-
./scripts/backup --action setup --namespace=wireguard --pvc=wireguard-data
3332
./scripts/backup --action setup --namespace=jellyfin --pvc=jellyfin-data
3433

3534
restore:
3635
./scripts/backup --action restore --namespace=actualbudget --pvc=actualbudget-data
37-
./scripts/backup --action restore --namespace=wireguard --pvc=wireguard-data
3836
./scripts/backup --action restore --namespace=jellyfin --pvc=jellyfin-data
3937

4038
test:

apps/wireguard/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name: wireguard
33
version: 0.0.0
44
dependencies:
55
- name: app-template
6-
version: 3.1.0
6+
version: 3.5.0
77
repository: https://bjw-s.github.io/helm-charts

apps/wireguard/values.yaml

+54-8
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ app-template:
88
tag: latest
99
env:
1010
LOG_CONFS: false
11-
PEERS: |
12-
KDDesktop
13-
KDLaptop
14-
KDPhone
11+
USE_COREDNS: true
1512
securityContext:
1613
capabilities:
1714
add:
@@ -25,8 +22,57 @@ app-template:
2522
port: 51820
2623
protocol: UDP
2724
persistence:
28-
data:
29-
accessMode: ReadWriteOnce
30-
size: 10Mi
25+
config:
26+
type: secret
27+
name: "{{ .Release.Name }}-secret"
3128
globalMounts:
32-
- path: /config
29+
- path: /config/wg_confs
30+
rawResources:
31+
secret:
32+
apiVersion: external-secrets.io/v1beta1
33+
kind: ExternalSecret
34+
spec:
35+
spec:
36+
secretStoreRef:
37+
kind: ClusterSecretStore
38+
name: global-secrets
39+
data:
40+
- secretKey: WIREGUARD_PRIVATE_KEY
41+
remoteRef:
42+
key: external
43+
property: wireguard-private-key
44+
target:
45+
template:
46+
data:
47+
wg0.conf: |
48+
[Interface]
49+
Address = 172.16.0.1/32
50+
ListenPort = 51820
51+
PrivateKey = {{ `{{ .WIREGUARD_PRIVATE_KEY }}` }}
52+
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
53+
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth+ -j MASQUERADE
54+
55+
# Note that WireGuard will ignore a peer whose public key matches
56+
# the interface's private key. So you can distribute a single
57+
# list of peers everywhere.
58+
# https://lists.zx2c4.com/pipermail/wireguard/2018-December/003703.html
59+
60+
[Peer]
61+
# homelab
62+
PublicKey = sSAZS1Z3vB7Wx8e2yVqXfeHjgWTa80wnSYoma3mZkiU=
63+
AllowedIPs = 172.16.0.1/32, 192.168.1.224/27
64+
65+
[Peer]
66+
# khuedoan-ryzentower
67+
PublicKey = 2poJnXVSbbaqY90B6ruupKEO4OrDFCur2s2pqTk1HWE=
68+
AllowedIPs = 172.16.0.10/32
69+
70+
[Peer]
71+
# khuedoan-thinkpadz13
72+
PublicKey = kgQbzrz+/P3Xd+L2hseKDYUjhwgfuQOro6tNz11ePH4=
73+
AllowedIPs = 172.16.0.11/32
74+
75+
[Peer]
76+
# khuedoan-phone
77+
PublicKey = nITHFdgTkNZOTWeSWqnGXjgwlCJMKRCnnUsjMx2yp2U=
78+
AllowedIPs = 172.16.0.12/32

external/terraform.tfvars.example

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extra_secrets = {
1818
# ../platform/global-secrets/files/secret-generator/config.yaml
1919
# Here's some examples of what you might want to add:
2020
#
21+
# wireguard-private-key = "wg genkey output here"
2122
# tailscale-auth-key = "tskey-auth-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
2223
# restic-password = "xxxxxxxxxxxxxxxxxxxxxxxx"
2324
# restic-s3-bucket = "https://s3.amazonaws.com/my-homelab-backup-xxxxxxxxxx"

flake.nix

+2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
opentofu # Drop-in replacement for Terraform
4040
p7zip
4141
pre-commit
42+
qrencode
4243
shellcheck
44+
wireguard-tools
4345
yamllint
4446

4547
(python3.withPackages (p: with p; [

0 commit comments

Comments
 (0)