Skip to content

Commit 2703207

Browse files
committed
Add example Kubernetes configuration
This commit adds an example of running Gluetun as a Kubernetes SidecarContainer. This setup has the benefit that Kubernetes will not start any main containers in a Pod until Gluetun is running and reporting a healthy status.
1 parent ee041f3 commit 2703207

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

setup/advanced/kubernetes.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,102 @@
11
# Kubernetes
22

3+
## Example Sidecar Container
4+
5+
> [!NOTE]
6+
> This configuration uses `restartPolicy: Always` which requires the
7+
> [SidecarContainers feature][sidecar-containers] introduced in
8+
> Kubernetes v1.29. Running Gluetun as a sidecar means that Kubernetes
9+
> will not start any items in the `containers:` section of the Pod if
10+
> Gluetun fails to start.
11+
12+
[sidecar-containers]: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/
13+
14+
```yaml
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
labels:
19+
app: gluetun-example
20+
name: gluetun-example
21+
spec:
22+
replicas: 1
23+
selector:
24+
matchLabels:
25+
app: gluetun-example
26+
template:
27+
metadata:
28+
labels:
29+
app: gluetun-example
30+
spec:
31+
initContainers:
32+
- name: gluetun
33+
image: 'qmcgaw/gluetun'
34+
restartPolicy: Always
35+
env:
36+
# Example Provider configuration for ProtonVPN with
37+
# variable configuration supplied by a Secret.
38+
- name: VPN_SERVICE_PROVIDER
39+
value: custom
40+
- name: VPN_TYPE
41+
value: wireguard
42+
- name: WIREGUARD_ADDRESSES
43+
value: '10.2.0.2/32'
44+
- name: VPN_ENDPOINT_PORT
45+
value: '51820'
46+
- name: WIREGUARD_PRIVATE_KEY
47+
valueFrom:
48+
secretKeyRef:
49+
name: proton-wireguard
50+
key: wireguard-privatekey
51+
- name: VPN_ENDPOINT_IP
52+
valueFrom:
53+
secretKeyRef:
54+
name: proton-wireguard
55+
key: wireguard-peer-endpoint
56+
- name: WIREGUARD_PUBLIC_KEY
57+
valueFrom:
58+
secretKeyRef:
59+
name: proton-wireguard
60+
key: wireguard-peer-publickey
61+
securityContext:
62+
# Required if using a container runtime that does not
63+
# share /dev/net/tun by default (e.g. runc v1.2.0 -- iv1.2.3)
64+
#privileged: true
65+
capabilities:
66+
add:
67+
- NET_ADMIN
68+
startupProbe:
69+
exec:
70+
command:
71+
- /gluetun-entrypoint
72+
- healthcheck
73+
initialDelaySeconds: 10
74+
timeoutSeconds: 5
75+
periodSeconds: 5
76+
failureThreshold: 3
77+
livenessProbe:
78+
exec:
79+
command:
80+
- /gluetun-entrypoint
81+
- healthcheck
82+
timeoutSeconds: 5
83+
periodSeconds: 5
84+
failureThreshold: 3
85+
86+
containers:
87+
# Main pod workload goes here. Netshoot is just an example.
88+
- name: netshoot
89+
image: nicolaka/netshoot
90+
command:
91+
- /bin/sh
92+
- '-c'
93+
- |
94+
while true; do
95+
curl -sS https://am.i.mullvad.net/json | jq
96+
sleep 60
97+
done
98+
```
99+
3100
## Common errors
4101
5102
### `adding IPv6 rule: ...: file exists`

0 commit comments

Comments
 (0)