vpn templates

This commit is contained in:
Ariel Sosnovsky committed 2023-04-17 15:45:59 -04:00
1 parent fbd317fa19
commit 110f97f44e
2 files changed
+76

No files matched your search

@@ -0,0 +1,56 @@
{{ define "homelab.openvpn.container" }}
- name: vpn
image: dperson/openvpn-client
command: ["/bin/sh","-c"]
args: ["openvpn --config 'vpn/client.ovpn' --auth-user-pass 'vpn/auth.txt' --script-security 3 --route-up /tmp/route/route-override.sh;"]
stdin: true
tty: true
securityContext:
privileged: true
capabilities:
add:
- NET_ADMIN
env:
- name: TZ
value: "Turkey"
volumeMounts:
- name: vpn-config
mountPath: /vpn/client.ovpn
subPath: client.ovpn
- name: vpn-config
mountPath: /vpn/auth.txt
subPath: auth.txt
- name: vpn-tmp
mountPath: /tmp/route
{{ end }}
{{ define "homelab.openvpn.initContainer" }}
- name: vpn-route-init
image: busybox
command: ['/bin/sh', '-c', 'cp /vpn/route-override.sh /tmp/route/route-override.sh; chown root:root /tmp/route/route-override.sh; chmod o+x /tmp/route/route-override.sh;']
volumeMounts:
- name: vpn-tmp
mountPath: /tmp/route
- name: route-script
mountPath: /vpn/route-override.sh
subPath: route-override.sh
{{ end }}
{{ define "homelab.openvpn.volumes" }}
- name: vpn-config
secret:
secretName: openvpn-creds
items:
- key: client.ovpn
path: client.ovpn
- key: auth.txt
path: auth.txt
- name: route-script
configMap:
name: openvpn-route-script
items:
- key: route-override.sh
path: route-override.sh
- name: vpn-tmp
emptyDir: {}
{{ end }}
@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: Secret
metadata:
name: openvpn-creds
type: Opaque
data:
_placeholder: ""
---
apiVersion: v1
kind: ConfigMap
metadata:
name: openvpn-route-script
data:
route-override.sh: |-
#!/bin/sh
VPN_GATEWAY=$(route -n | awk 'NR==3' | awk '{ print $2 }')
ip route del 0.0.0.0/1 via $VPN_GATEWAY
echo "Route Updated"