All Projects → pieterlange → Kube Openvpn

pieterlange / Kube Openvpn

Licence: mit
🔐 Kubernetes native OpenVPN

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Kube Openvpn

chef-openvpn
A multi-configuration OpenVPN server cookbook featuring IPv6 support and easy setup of client files.
Stars: ✭ 23 (-93.05%)
Mutual labels:  openvpn, vpn
desktop-app-daemon
Official IVPN Desktop app (service)
Stars: ✭ 34 (-89.73%)
Mutual labels:  openvpn, vpn
nordvpn
NordVpn Docker Client
Stars: ✭ 475 (+43.5%)
Mutual labels:  openvpn, vpn
netmaker
Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.
Stars: ✭ 4,147 (+1152.87%)
Mutual labels:  openvpn, vpn
Passepartout Apple
User-friendly OpenVPN client app for iOS and macOS.
Stars: ✭ 284 (-14.2%)
Mutual labels:  vpn, openvpn
killswitch-windows
VPN kill switch for windows.
Stars: ✭ 22 (-93.35%)
Mutual labels:  openvpn, vpn
Android Vpn Client Ics Openvpn
⭐ Create your Android VPN App by using Android Studio and publish to Google Play Store 🤖
Stars: ✭ 270 (-18.43%)
Mutual labels:  vpn, openvpn
iit-kgp-network
Information repository and Solutions on IIT KGP Internet Problems.
Stars: ✭ 28 (-91.54%)
Mutual labels:  openvpn, vpn
watchblob
Connect to 2-factor WatchGuard VPNs on Linux with OpenVPN
Stars: ✭ 15 (-95.47%)
Mutual labels:  openvpn, vpn
linux-cli-community
Linux command-line client for ProtonVPN. Written in Python.
Stars: ✭ 1,166 (+252.27%)
Mutual labels:  openvpn, vpn
desktop-app-ui2
IVPN Desktop app
Stars: ✭ 19 (-94.26%)
Mutual labels:  openvpn, vpn
yubi-oath-vpn
Simply insert your Yubikey and connect automatically to your TOTP-2FA-VPN.
Stars: ✭ 15 (-95.47%)
Mutual labels:  openvpn, vpn
Raspberry-Pi-VPN-Gateway
Raspberry Pi VPN gateway installer for Private Internet Access
Stars: ✭ 44 (-86.71%)
Mutual labels:  openvpn, vpn
openvpn-unroot
Run OpenVPN without root privileges
Stars: ✭ 27 (-91.84%)
Mutual labels:  openvpn, vpn
desktop-app
Official IVPN Desktop app
Stars: ✭ 141 (-57.4%)
Mutual labels:  openvpn, vpn
AdGuard-WireGuard-Unbound-Cloudflare
The Ultimate Network Security Guide 🔒 Protection | 🔎 Privacy | 🚀 Performance on home network 24/7 🕛 Accessible anywhere 🌏
Stars: ✭ 160 (-51.66%)
Mutual labels:  openvpn, vpn
desktop-app-cli
Official IVPN command-line interface (CLI)
Stars: ✭ 18 (-94.56%)
Mutual labels:  openvpn, vpn
droidovpn
An unofficial VPN Gate client for Android.
Stars: ✭ 65 (-80.36%)
Mutual labels:  openvpn, vpn
Open2Nord
A Python script that makes connecting to NordVPN servers through OpenVPN GUI a lot easier, and adds extra functionality
Stars: ✭ 22 (-93.35%)
Mutual labels:  openvpn, vpn
k8s-ovpn-chart
[DEPRECATED] Helm chart for a private OpenVPN server
Stars: ✭ 19 (-94.26%)
Mutual labels:  openvpn, vpn

kube-openvpn

Docker Repository on Quay Docker Repository on Docker Hub

Synopsis

Simple OpenVPN deployment using native kubernetes semantics. There is no persistent storage, CA management (key storage, cert signing) needs to be done outside of the cluster for now. I think this is better - unless you leave your keys on your dev laptop.

Motivation

The main motivator for this project was having the ability to route service requests back to local apps (running on the VPN client), making life much easier for development environments where developers cannot run the entire app stack locally but need to iterate on 1 app quickly.

Usage

First, you need to initialize your PKI infrastructure. Easyrsa is bundled in this container, so this is fairly easy. Replace OVPN_SERVER_URL with your endpoint to-be.

$ docker run --user=$(id -u) -e OVPN_SERVER_URL=tcp://vpn.my.fqdn:1194 -v $PWD:/etc/openvpn:z -ti ptlange/openvpn ovpn_initpki

Follow the instructions on screen. Remember (or better: securely store) your secure password for the CA. You are now left with a pki folder in your current working directory.

Generate the initial Certificate Revocation List. This file needs to be updated every $EASYRSA_CRL_DAYS. All clients will be blocked when this file expires.

$ docker run --user=$(id -u) -e EASYRSA_CRL_DAYS=180 -v $PWD:/etc/openvpn:z -ti ptlange/openvpn easyrsa gen-crl

Getting service_cidr and pod_cidr within google cloud:

service_cidr:

gcloud container clusters describe <your clustername> | grep servicesIpv4Cidr

pod_cidr:

gcloud container clusters describe <your clustername> | grep clusterIpv4Cidr

Deploy the VPN server (namespace needs to exist already):

$ ./kube/deploy.sh
Usage: ./kube/deploy.sh <namespace> <OpenVPN URL> <service cidr> <pod cidr>

$ ./kube/deploy.sh default tcp://vpn.my.fqdn:1194 10.3.0.0/24 10.2.0.0/16
secret "openvpn-pki" created
configmap "openvpn-settings" created
configmap "openvpn-ccd" created
deployment "openvpn" created
You have exposed your service on an external port on all nodes in your
cluster.  If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:30xxx) to serve traffic.

See http://releases.k8s.io/release-1.3/docs/user-guide/services-firewalls.md for more details.
service "openvpn-ingress" created

Your VPN endpoint is now reachable on every node in the cluster on port 30XXX. This port can be easily exposed by setting the Type field of the openvpn Service to LoadBalancer if you're running your cluster within a public cloud. Assign the correct CNAME/A address to your loadbalancer or replace the original servername with the DNS name of your newly created loadbalancer in your client configuration.

Accessing the cluster

With the pki still in $PWD/pki we can create a new VPN user and grab the .ovpn configuration file:

# Generate VPN client credentials for CLIENTNAME without password protection; leave 'nopass' out to enter password
$ docker run --user=$(id -u) -v $PWD:/etc/openvpn:z -ti ptlange/openvpn easyrsa build-client-full CLIENTNAME nopass
$ docker run --user=$(id -u) -e OVPN_SERVER_URL=tcp://vpn.my.fqdn:1194 -v $PWD:/etc/openvpn:z --rm ptlange/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn

CLIENTNAME.ovpn can now be used to connect to the cluster and interact with k8s services and pods directly. Whoohoo!

One-way traffic

Routing back to the client

In order to route cluster traffic back to a service running on the client, we need to assign CLIENTNAME a static IP. If you have not configured an $OVPN_NETWORK you need to pick something in the 10.140.0.0/24 range.

Edit the CCD (client configuration directory) configmap:

$ kubectl edit configmap openvpn-ccd

Look at the example and add another entry for the CLIENTNAME you added before. You do not have to restart openvpn but if you are already connected you will need to reconnect to get the static IP.

Next you have to define what port on the openvpn pod to route back to the client. The port forwarding will automatically load after the configmap has been updated.

$ kubectl edit configmap openvpn-portmapping

Two-way traffic

You can now reach the openvpn client! If you want to substitute a kubernetes service for a service running on the client, simply modify the label selector to match your openvpn endpoint address and the targetPort just configured in the openvpn-portmapping configmap.

Exampe service definition routing service myapp on port 80 to the example client's service running on port 80.

apiVersion: v1
kind: Service
metadata:
  name: myapp
spec:
  ports:
  - port: 80
    targetPort: 20080
  selector:
    openvpn: vpn.my.fqdn

Custom openvpn configuration

User-specific settings need to be set in the client config directory by editing the openvpn-ccd ConfigMap

You can also use your own openvpn configuration by mounting in a openvpn.tmpl file in /etc/openvpn/templates/. Create your own openvpn.tmpl from the example in this repository. Load it into a configmap with kubectl create configmap openvpn-template --from-file=openvpn.tmpl. Now edit the openvpn deployment configuration and add in an extra mountpoint at /etc/openvpn/templates for the openvpn-template configmap.

Note that you can use environment variables in the template!

Updating the CRL

Use the crl-update.sh script. This extends the CRL for another 182 days by default. If you automate this i recommend setting this far shorter.

$ ./kube/update-crl default

Tests

NONE. See next section.

Contributing

Please file issues on github. PR's are welcomed.

Thanks

I used kylemanna/openvpn extensively for a long time and lend quite a few of his scripts for easing the PKI handling. offlinehacker/openvpn-k8s provided some inspiration as well and showed i can run openvpn without any persistent storage, prompting me to write this collection of scripts.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].