Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit ee54af8

Browse files
authored
Merge pull request #38 from DavideWalder/helm
Add Helm chart
2 parents 3dfa177 + 368b17f commit ee54af8

File tree

11 files changed

+429
-0
lines changed

11 files changed

+429
-0
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: https://github.com/norwoodj/helm-docs
3+
rev: v1.6.0
4+
hooks:
5+
- id: helm-docs
6+
args:
7+
- --chart-search-root=chart
8+
- --template-files=./_templates.gotmpl
9+
- --template-files=README.md.gotmpl

chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/Chart.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v2
2+
name: openvpn-client
3+
description: A Helm chart for an OpenVPN client with HTTP and SOCKS5 proxies
4+
type: application
5+
6+
# This is the chart version. This version number should be incremented each time you make changes
7+
# to the chart and its templates, including the app version.
8+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
9+
version: 0.1.0
10+
11+
# This is the version number of the application being deployed. This version number should be
12+
# incremented each time you make changes to the application. Versions are not expected to
13+
# follow Semantic Versioning. They should reflect the version the application is using.
14+
# It is recommended to use it with quotes.
15+
appVersion: "v1.2.1"

chart/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# openvpn-client
2+
3+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.2.1](https://img.shields.io/badge/AppVersion-v1.2.1-informational?style=flat-square)
4+
5+
A Helm chart for an OpenVPN client with HTTP and SOCKS5 proxies
6+
7+
## Values
8+
9+
| Key | Type | Default | Description |
10+
|-----|------|---------|-------------|
11+
| affinity | object | `{}` | |
12+
| auth.enabled | bool | `false` | Whether to turn on authentication for the proxies |
13+
| auth.existingSecret | string | `""` | Existing secret containing the credentials for accessing the proxies. |
14+
| auth.proxyPassword | string | `""` | |
15+
| auth.proxyUsername | string | `""` | |
16+
| autoscaling.enabled | bool | `false` | |
17+
| autoscaling.maxReplicas | int | `100` | |
18+
| autoscaling.minReplicas | int | `1` | |
19+
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
20+
| configFiles.files | object | `{}` | OpenVPN config files |
21+
| configFiles.openVPNConfig | string | `""` | The OpenVPN config file to use. If this is unset, the first file with the extension `.conf` will be used. |
22+
| fullnameOverride | string | `""` | |
23+
| httpProxy.enabled | bool | `false` | The on/off status of Tinyproxy, the built-in HTTP proxy server. |
24+
| image.pullPolicy | string | `"IfNotPresent"` | |
25+
| image.repository | string | `"ghcr.io/wfg/openvpn-client"` | |
26+
| image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. |
27+
| killSwitch.enabled | bool | `true` | The on/off status of the network kill switch. |
28+
| listenOn | string | `""` | Address the proxies will be listening on. Set to `0.0.0.0` to allow all IP addresses. |
29+
| nameOverride | string | `""` | |
30+
| nodeSelector | object | `{}` | |
31+
| podAnnotations | object | `{}` | |
32+
| replicaCount | int | `1` | |
33+
| resources | object | `{}` | |
34+
| service.type | string | `"ClusterIP"` | |
35+
| socksProxy.enabled | bool | `false` | The on/off status of Dante, the built-in SOCKS proxy server. |
36+
| subnets | list | `[]` | A list of one or more subnets to allow outside of the VPN tunnel. |
37+
| tolerations | list | `[]` | |
38+
| vpnLogLevel | int | `3` | OpenVPN verbosity (`1`-`11`) |
39+
40+
----------------------------------------------
41+
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)

chart/templates/_helpers.tpl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "openvpn-client.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "openvpn-client.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "openvpn-client.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "openvpn-client.labels" -}}
37+
helm.sh/chart: {{ include "openvpn-client.chart" . }}
38+
{{ include "openvpn-client.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "openvpn-client.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "openvpn-client.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Convert boolean to on/off
55+
*/}}
56+
{{- define "openvpn-client.boolean" -}}
57+
{{- if .enabled }} "on" {{- else }} "off" {{- end }}
58+
{{- end }}
59+
60+
{{/*
61+
Define auth secret name
62+
*/}}
63+
{{- define "openvpn-client.authSecretName" -}}
64+
{{- if .Values.auth.existingSecret -}}
65+
{{- .Values.auth.existingSecret -}}
66+
{{- else -}}
67+
{{- include "openvpn-client.fullname" . | printf "%s-auth" }}
68+
{{- end -}}
69+
{{- end -}}
70+
71+
{{/*
72+
Define config secret name
73+
*/}}
74+
{{- define "openvpn-client.configSecretName" -}}
75+
{{- include "openvpn-client.fullname" . | printf "%s-config" }}
76+
{{- end -}}

chart/templates/auth-secret.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if and .Values.auth.enabled (not .Values.auth.existingSecret) (or .Values.httpProxy.enabled .Values.socksProxy.enabled) -}}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ include "openvpn-client.authSecretName" . }}
6+
labels:
7+
{{- include "openvpn-client.labels" . | nindent 4 }}
8+
type: kubernetes.io/basic-auth
9+
data:
10+
username: {{ .Values.auth.proxyUsername | b64enc | quote }}
11+
password: {{ .Values.auth.proxyPassword | b64enc | quote }}
12+
{{- end -}}

chart/templates/config-secret.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "openvpn-client.configSecretName" . }}
5+
labels:
6+
{{- include "openvpn-client.labels" . | nindent 4 }}
7+
type: Opaque
8+
data:
9+
{{- range $fileName, $fileContent := $.Values.configFiles.files }}
10+
{{ $fileName }}: |-
11+
{{- $fileContent | b64enc | nindent 4 }}
12+
{{- end }}

chart/templates/deployment.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "openvpn-client.fullname" . }}
5+
labels:
6+
{{- include "openvpn-client.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "openvpn-client.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "openvpn-client.selectorLabels" . | nindent 8 }}
22+
spec:
23+
initContainers:
24+
- name: copy
25+
image: busybox
26+
command: ["/bin/sh", "-c", "cp -r /from/. /to"]
27+
volumeMounts:
28+
- name: openvpn-client
29+
mountPath: /from
30+
- name: configs
31+
mountPath: /to
32+
containers:
33+
- name: {{ .Chart.Name }}
34+
securityContext:
35+
capabilities:
36+
add:
37+
- NET_ADMIN
38+
privileged: true
39+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
40+
imagePullPolicy: {{ .Values.image.pullPolicy }}
41+
ports:
42+
{{- if .Values.socksProxy.enabled }}
43+
- containerPort: 1080
44+
{{- end }}
45+
{{- if .Values.httpProxy.enabled }}
46+
- containerPort: 8080
47+
{{- end }}
48+
readinessProbe:
49+
exec:
50+
command: ["ping", "-c", "3", "1.1.1.1"]
51+
env:
52+
- name: VPN_LOG_LEVEL
53+
value: {{ .Values.vpnLogLevel | quote }}
54+
- name: SOCKS_PROXY
55+
value: {{- include "openvpn-client.boolean" .Values.socksProxy }}
56+
- name: HTTP_PROXY
57+
value: {{- include "openvpn-client.boolean" .Values.httpProxy }}
58+
- name: KILL_SWITCH
59+
value: {{- include "openvpn-client.boolean" .Values.killSwitch }}
60+
{{- if .Values.listenOn }}
61+
- name: LISTEN_ON
62+
value: {{ .Values.listenOn }}
63+
{{- end }}
64+
{{- if .Values.subnets }}
65+
- name: SUBNETS
66+
value: {{ join "," .Values.subnets | quote }}
67+
{{- end }}
68+
{{- if .Values.auth.enabled }}
69+
- name: PROXY_USERNAME
70+
valueFrom:
71+
secretKeyRef:
72+
name: {{ include "openvpn-client.authSecretName" . }}
73+
key: username
74+
- name: PROXY_PASSWORD
75+
valueFrom:
76+
secretKeyRef:
77+
name: {{ include "openvpn-client.authSecretName" . }}
78+
key: password
79+
{{- end }}
80+
{{- with .Values.configFiles.openVPNConfig }}
81+
- name: VPN_CONFIG_FILE
82+
value: {{ . }}
83+
{{- end }}
84+
volumeMounts:
85+
- mountPath: /data/vpn
86+
name: configs
87+
resources:
88+
{{- toYaml .Values.resources | nindent 12 }}
89+
{{- with .Values.nodeSelector }}
90+
nodeSelector:
91+
{{- toYaml . | nindent 8 }}
92+
{{- end }}
93+
{{- with .Values.affinity }}
94+
affinity:
95+
{{- toYaml . | nindent 8 }}
96+
{{- end }}
97+
{{- with .Values.tolerations }}
98+
tolerations:
99+
{{- toYaml . | nindent 8 }}
100+
{{- end }}
101+
volumes:
102+
- name: openvpn-client
103+
secret:
104+
secretName: {{ include "openvpn-client.configSecretName" . }}
105+
- name: configs
106+
emptyDir: {}

chart/templates/hpa.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta1
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "openvpn-client.fullname" . }}
6+
labels:
7+
{{- include "openvpn-client.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "openvpn-client.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
21+
{{- end }}
22+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: memory
26+
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
27+
{{- end }}
28+
{{- end }}

chart/templates/service.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if or .Values.socksProxy.enabled .Values.httpProxy.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "openvpn-client.fullname" . }}
6+
labels:
7+
{{- include "openvpn-client.labels" . | nindent 4 }}
8+
spec:
9+
type: {{ .Values.service.type }}
10+
ports:
11+
{{- if .Values.socksProxy.enabled }}
12+
- port: 1080
13+
protocol: TCP
14+
name: socks5
15+
{{- end }}
16+
{{- if .Values.httpProxy.enabled }}
17+
- port: 8080
18+
protocol: TCP
19+
name: http
20+
{{- end }}
21+
selector:
22+
{{- include "openvpn-client.selectorLabels" . | nindent 4 }}
23+
{{- end }}

0 commit comments

Comments
 (0)