Wiring the port via "${PIA_OPENVPN_PORT}" made Flux/kustomize emit an unquoted
53 (int) after substitution, which k8s rejects for an env value ("expected
string, got 53"). Same gotcha as the Longhorn numberOfReplicas fix. Hardcode the
quoted string; cluster-var removed with a NOTE explaining why.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
108 lines
4.6 KiB
YAML
108 lines
4.6 KiB
YAML
---
|
|
# Gluetun — the single shared in-cluster VPN egress gateway (ADR-0013): PIA over OpenVPN-UDP, with
|
|
# Gluetun's built-in kill-switch/firewall (fail-closed), health checks, auto-reconnect, and native
|
|
# port forwarding for qBittorrent. `vpn`-class pods are steered through this gateway (see README.md
|
|
# "Egress steering" — the Cilium-native mechanism, pending live validation with PIA creds).
|
|
#
|
|
# Credentials: the `pia-credentials` SOPS Secret (keys: username, password). Gluetun uses PIA's
|
|
# username/password (via OPENVPN_USER/OPENVPN_PASSWORD) to authenticate to PIA. Gluetun ships PIA's
|
|
# OpenVPN server configs, so no manual `.ovpn` is needed (ADR-0013 amendment: OpenVPN-UDP — Gluetun
|
|
# does NOT support PIA over WireGuard).
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: gluetun
|
|
namespace: vpn-egress
|
|
labels:
|
|
app: gluetun
|
|
spec:
|
|
replicas: 1 # ONE shared tunnel (ADR-0013). Active/standby is a later enhancement.
|
|
strategy:
|
|
type: Recreate # a tunnel is a singleton — never run two overlapping during a rollout
|
|
selector:
|
|
matchLabels:
|
|
app: gluetun
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: gluetun
|
|
spec:
|
|
containers:
|
|
- name: gluetun
|
|
image: qmcgaw/gluetun:v3.41.0 # pinned; Renovate bumps. PIA is OpenVPN-only in Gluetun
|
|
# (WireGuard for PIA is unsupported upstream — ADR-0013
|
|
# amendment; thrnz/docker-wireguard-pia is the WG fallback).
|
|
securityContext:
|
|
capabilities:
|
|
add: ["NET_ADMIN"] # required for the tunnel + firewall
|
|
env:
|
|
- name: VPN_SERVICE_PROVIDER
|
|
value: "private internet access"
|
|
- name: VPN_TYPE
|
|
value: "openvpn" # OpenVPN-UDP — satisfies "protocol != TCP" (R-NET); ADR-0013 amended
|
|
- name: OPENVPN_ENDPOINT_PORT
|
|
value: "53" # NOT 1197 — the home network NATs its own OpenVPN server there,
|
|
# so PIA-on-1197 replies never return (tcpdump-confirmed; DECISIONS-LOG).
|
|
# Hardcoded (not a ${var}): Flux/kustomize strips quotes on "${VAR}"
|
|
# → int coercion, which k8s rejects for env value (Longhorn-fix gotcha).
|
|
# Valid PIA ports: 53, 1194, 1197, 1198, 8080, 9201.
|
|
# PIA credentials from the SOPS secret (Gluetun's PIA OpenVPN creds env):
|
|
- name: OPENVPN_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: pia-credentials
|
|
key: username
|
|
- name: OPENVPN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: pia-credentials
|
|
key: password
|
|
- name: SERVER_REGIONS
|
|
value: "${PIA_REGION}" # cluster-vars: a PF-CAPABLE PIA region (ADR-0013 PF caveat)
|
|
- name: VPN_PORT_FORWARDING
|
|
value: "on" # PIA native port forwarding for qBittorrent
|
|
- name: FIREWALL
|
|
value: "on" # KILL-SWITCH: block all egress except the tunnel (fail-closed, R-NET-06)
|
|
- name: FIREWALL_OUTBOUND_SUBNETS
|
|
value: "${CLUSTER_POD_CIDR}" # allow steered client pods (pod CIDR) to route out via the tunnel
|
|
- name: DOT
|
|
value: "off" # DNS via cluster CoreDNS, not Gluetun's DoT
|
|
ports:
|
|
- name: control
|
|
containerPort: 8000 # Gluetun control API (health + forwarded-port lookup)
|
|
livenessProbe:
|
|
httpGet: { path: /v1/openvpn/status, port: 8000 } # Gluetun control API health
|
|
initialDelaySeconds: 20
|
|
periodSeconds: 30
|
|
resources:
|
|
requests:
|
|
cpu: 50m
|
|
memory: 64Mi
|
|
limits:
|
|
memory: 160Mi
|
|
volumeMounts:
|
|
- name: tun
|
|
mountPath: /dev/net/tun
|
|
volumes:
|
|
- name: tun
|
|
hostPath:
|
|
path: /dev/net/tun
|
|
type: CharDevice
|
|
---
|
|
# Control API Service — the port-sync helper (qbittorrent-natmap, README) reads the PIA-assigned
|
|
# forwarded port from here; also used for tunnel-state health/alerting (ADR-0013 "alert on tunnel state").
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: gluetun-control
|
|
namespace: vpn-egress
|
|
labels:
|
|
app: gluetun
|
|
spec:
|
|
selector:
|
|
app: gluetun
|
|
ports:
|
|
- name: control
|
|
port: 8000
|
|
targetPort: 8000
|