openvpn
by Helm
A Helm chart for OpenVPN
About this chart
OpenVPN
Deploy your own OpenVPN server running in Kubernetes to access internal cluster resources using GitHub backed authentication for user & group management.
Table of Contents
- Quick start
- Introduction
- Features
- Prerequisites
- Installing the Chart
- Uninstalling the Chart
- Configuration
- Github authorization support
- Github team based ACL
- Two-Factor authorization
- UI
- HTTPS with Let's Encrypt
- Using VPN
- Client generated config
- Connect VPN
- Understand chart
Quick start
$ helm repo rm cloudposse-incubator 2>/dev/null
$ helm repo add cloudposse-incubator https://charts.cloudposse.com/incubator/
$ helm install --set host={host} cloudposse-incubator/openvpn
Introduction
This chart installs OpenVPN on a Kubernetes cluster using the Helm package manager.
Features
- OpenVPN
- VPN authorization based on Github credentials using Github-PAM
- Simple web UI to download generated generated OpenVPN client config file
- HTTPS for UI based on Let's encrypt
Prerequisites
- Kubernetes 1.4+ with Beta APIs enabled
- PV provisioner support in the underlying infrastructure
- Route53 Kubernetes
Installing the Chart
Add charts repo
$ helm repo rm cloudposse-incubator 2>/dev/null
$ helm repo add cloudposse-incubator https://charts.cloudposse.com/incubator/
We recommend to install into kube-system namespace.
To install the chart:
$ helm install --namespace kube-system --name vpn cloudposse-incubator/openvpn
The command deploys OpenVPN on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.
Tip: List all releases using
helm list
Uninstalling the Chart
To uninstall/delete the vpn deployment:
$ helm delete --purge vpn
This command removes all the Kubernetes components associated with the chart and deletes the release.
Configuration
The following table lists the configurable parameters of the OpenVPN chart and their default values.
| Parameter | Description | Default |
|---|---|---|
host | VPN gateway hostname | REQUIRED TO BE SPECIFIED |
github_team | GitHub team in format {org}/{team} | REQUIRED TO BE SPECIFIED |
secret | Secret name to store openvpn certificates | openvpn-secret |
ui.enabled | Enable UI | true |
ui.ssl.enabled | Use https for UI | false |
ui.ssl.prod | Use production ready SSL certificate | false |
ui.ssl.email | Email for notifications | REQUIRED TO BE SPECIFIED if ui.ssl.enabled=true |
ui.ssl.secret | Secret name to store SSL certificates | openvpn-letsencrypt-secret |
Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,
$ helm install --name vpn \
--set host=test.com \
--set github_team={company}/{team} \
incubator/openvpn
The above command sets the host parameter to 'test.com' and install vpn acceptable with that host.
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
$ helm install --name vpn -f values.yaml incubator/openvpn
Tip: You can use the default values.yaml for reference.
Tip: We expose only the most common options in the table above. There are many more options that can be tweaked in the values.yaml.
GitHub Authorization Support
This chart use Github PAM for all authorization purpose. Everywhere you will need login\password use your github.com onces.
GitHub Team Based ACLs
You must specify a GitHub team that should be used to control access to the VPN.
The team in format should be {organization name}/{team name} as value for the github_team parameter.
Two-Factor Authorization
If you use Two-Factor authentication on your github.com account, then you will need to append the MFA code to the end of your password, separated by a space.
Example:
Login: user1 Password: qwerty Current MFA code: 123 456
Enter values
| Login field | Password field |
|---|---|
user1 | qwerty 123456 |
UI
There is very basic web UI which allow users to download the pre-generated OpenVPN client configuration that can be
used to import VPN connection to their client. To enable the web UI set the value of ui.enabled=true. By default, the UI is enabled.
UI can be accessed at http://{host}, the same host that you would use as the endpoint for the VPN.
HTTPS with Let's Encrypt
If ui.ssl.enabled=true, then the UI would be accessed at https://{host}.
The SSL certificate will be signed by Let's Encrypt and be accepted by all modern web browsers.
WARNING: You must specify the
ui.ssl.email={your email}in order for the SSL certificates to be generated successfully.
Let's Encrypt has HARD rate limits.
Production ready certificates have low rate limits (like ~12 a day), so by default you should use the staging certificates to avoid getting blocked! You've been warned.
Set ui.ssl.prod=true to enable production ready certificate.
Using VPN
To connect to the VPN, you need to download the pre-generated client configuration and then connect to OpenVPN
Client Generated Config
You can download the client configuration file (client.ovpn) from the UI at http(s)://{host}.
If the UI is disabled, then you retrieve the client configuration with the following command. It requires access to the Kubernetes API.
kubectl get secret {secret} --template='{{.data.client}}' | base64 -d > client.ovpn
Connect VPN
Connect to the VPN using the pre-generated client configuration client.ovpnby following the
instructions for your OS.
All propmpts for login & password will accept your github.com login & password. You can read more here about how it works.
Understanding this Chart
This is a necessarily complex chart due to some limitations of Helm, so this information can be useful for troubelshooting.
Chart consists of 4 parts
- OpenVPN
- SSL Terminator (if ui.enabled and ui.ssl.enabled)
- Let's Encrypt Bot (if ui.enabled and ui.ssl.enabled)
- UI Dashboard (if ui.enabled)
Installation process several stages before vpn would became ready to use.
- Pre-Install Stage
- OpenVPN generates certificates and save them to the k8s secret
{secret} - If
ui.enabledandui.ssl.enabled, then the Let's Encrypt Bot generates SSL certificates and saves them to the k8s secret{ui.ssl.secret}
- Install Stage
- If ui.enabled create Dashboard deployment, service, configmap.
- If ui.enabled and ui.ssl.enabled create Let's encrypt bot deployment, service.
- If ui.enabled and ui.ssl.enabled create SSL terminator deployment, service.
- Create OpenVPN deployment, service (annotated for route53-kubernetes), configmap.
- Post-Install Stage
- route53-kubernetes adds DNS record that points to the OpenVPN Service
- If
ui.enabledandui.ssl.enabled, then the Let's Encrypt Bot waits until new DNS records are resolved - If
ui.enabledandui.ssl.enabled, then the Let's Encrypt Bot tries to get a new certificate - Upon successful acquisition of new Let's Encrypt certificate, then restart the SSL Terminator Deployment
VPN is ready for use.
Deploy openvpn with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has openvpn on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartopenvpn is pinned at v0.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply