VPN on Kubernetes

Ayi angio
FAUN — Developer Community 🐾
3 min readJul 4, 2022

--

Photo by Privecstasy on Unsplash

Hai Everyone, in this article I want to share about VPN on Kubernetes cluster, one of the free open-source tools is Pritunl.

Pritunl is one of the free VPN open-source and has unlimited users and devices connected to it

Pritunl will be run on a Kubernetes cluster, before that we need to prepare some tools before installing Pritunl.

Prerequisites

  • Kustomize Version 4. x Or Newer
  • Kubectl
  • Helm Version 3 or Newer
  • Kubernetes Cluster 1.22 or Newer

Steps

  1. Install MongoDB
  • Add repository helm chart monggo and update your repository
$ helm repo add bitnami https://charts.bitnami.com/bitnami$ helm repo update
  • Install Monggo with helm, in this command use namespace VPN and you can fit with your namespace on cluster
helm install monggo bitnami/mongodb -n vpn

2. Install Pritunl

  • Get Password root MongoDB
kubectl get secret --namespace vpn monggo-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 -d
  • Create file Deployment.yaml
Deployment.yaml

The value ENV container depends on your domain cluster k8s, you can see how to write domain local Kubernetes here https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

  • Create file service-tcp.yaml
service-tcp.yaml

this yaml for exposing your server and dashboard Pritunl

  • Create file service-udp.yaml
service-udp.yaml

this yaml works for connecting to the internet

  • Create file kustomization.yaml
kustomization.yaml
  • Verify your file installation with kustomize
kustomize build . | kubectl diff -f -
  • If there is no error then install pritunl with kustomize
kustomize build . | kubectl apply -f -
  • Create Ingress.yaml for service TCP
ingress.yaml

3. Config Pritunl Server

  • Login to pritunl dashboard with username and password default (pritunl)
  • Setup Username and password Admin and set your IP public and save
  • Add Org on menubar Users
  • Create a new user, fill in your name, email, and Pin (for auth on client application)
  • Add server and set up your name server, port for protocol UDP (must be same as your port on the cluster), and DNS server (in this case use DNS google) then add
  • Attach your organization to your server
  • Start your server
  • Finally your server ready to use

4. Connect to VPN

  • Download Temporary URL Profile
  • Open your pritunl client and import your profile file
  • Connect to your VPN and input your PIN, and see your profile online right now

Reference

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Developers: Learn and grow by keeping up with what matters, JOIN FAUN.

--

--