add some strucutre

This commit is contained in:
Stavros kois
2023-05-22 14:48:26 +03:00
parent 63f7ba1adb
commit 28d8a10c03
13 changed files with 387 additions and 0 deletions
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common
version: 1.0.7
digest: sha256:919bcf42446fc1748a1b77001ec0161bb7a72a198381794b716a6ebb459ac31b
generated: "2023-05-16T15:42:24.207377102+03:00"
@@ -0,0 +1,11 @@
gluetunStorage:
data:
type: hostPath
hostPath: /mnt/{{ .Release.Name }}/data
# https://github.com/qdm12/gluetun/wiki/AirVPN
gluetunConfig:
provider: airvpn
type: openvpn
openvpnKey: 'some key'
openvpnCert: 'some cert'
@@ -0,0 +1,159 @@
groups:
- name: Gluetun Configuration
description: Configure Gluetun
- name: User and Group Configuration
description: Configure User and Group for Gluetun
- name: Network Configuration
description: Configure Network for Gluetun
- name: Storage Configuration
description: Configure Storage for Gluetun
- name: Resources Configuration
description: Configure Resources for Gluetun
questions:
- variable: TZ
group: Gluetun Configuration
label: Timezone
schema:
type: string
default: Etc/UTC
required: true
$ref:
- definitions/timezone
- variable: gluetunConfig
label: ""
group: Gluetun Configuration
schema:
type: dict
attrs:
- variable: additionalEnvs
label: Additional Environment Variables
description: Configure additional environment variables for Gluetun.
schema:
type: list
default: []
items:
- variable: env
label: Environment Variable
schema:
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: value
label: Value
schema:
type: string
required: true
- variable: gluetunID
label: ""
group: User and Group Configuration
schema:
type: dict
attrs:
- variable: user
label: User ID
description: The user id that Gluetun files will be owned by.
schema:
type: int
min: 568
default: 568
required: true
- variable: group
label: Group ID
description: The group id that Gluetun files will be owned by.
schema:
type: int
min: 568
default: 568
required: true
- variable: gluetunNetwork
label: ""
group: Network Configuration
schema:
type: dict
attrs:
- variable: hostNetwork
label: Host Network
description: Bind to the host network.
schema:
type: boolean
default: false
- variable: gluetunStorage
label: ""
group: Storage Configuration
schema:
type: dict
attrs:
- variable: data
label: Gluetun Data Storage
description: The path to store Gluetun data.
schema:
type: dict
attrs:
- variable: type
label: Type
description: |
ixVolume: Is dataset created automatically by the system.</br>
Host Path: Is a path that already exists on the system.
schema:
type: string
required: true
default: ixVolume
enum:
- value: hostPath
description: Host Path (Path that already exists on the system)
- value: ixVolume
description: ixVolume (Dataset created automatically by the system)
- variable: datasetName
label: Dataset Name
schema:
type: string
show_if: [["type", "=", "ixVolume"]]
required: true
hidden: true
immutable: true
default: "data"
$ref:
- "normalize/ixVolume"
- variable: hostPath
label: Host Path
schema:
type: hostpath
show_if: [["type", "=", "hostPath"]]
immutable: true
required: true
- variable: resources
label: ""
group: Resources Configuration
schema:
type: dict
attrs:
- variable: limits
label: Limits
schema:
type: dict
attrs:
- variable: cpu
label: CPU
description: CPU limit for Gluetun.
schema:
type: string
default: 4000m
required: true
- variable: memory
label: Memory
description: Memory limit for Gluetun.
schema:
type: string
default: 8Gi
required: true
@@ -0,0 +1 @@
{{ include "ix.v1.common.lib.chart.notes" $ }}
@@ -0,0 +1,23 @@
{{- define "gluetun.configuration" -}}
{{- include "gluetun.validation" $ }}
configmap:
gluetun:
enabled: true
data:
VPN_SERVICE_PROVIDER: {{ .Values.gluetunConfig.provider }}
VPN_TYPE: {{ .Values.gluetunConfig.type }}
{{- include (printf "gluetun.%v.%v.env" .Values.gluetunConfig.provider .Values.gluetunConfig.type) $ | nindent 6 }}
{{- include "gluetun.configs.common.env" $ | nindent 6 }}
{{- if eq .Values.gluetunConfig.type "openvpn" }}
{{- with .Values.gluetunConfig.openvpnUser }}
OPENVPN_USER: {{ . }}
{{- end }}
{{- with .Values.gluetunConfig.openvpnPassword }}
OPENVPN_PASSWORD: {{ . }}
{{- end }}
{{- else if eq .Values.gluetunConfig.type "wireguard" }}
{{- end }}
{{- end -}}
@@ -0,0 +1,77 @@
{{- define "gluetun.workload" -}}
workload:
gluetun:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: {{ .Values.gluetunNetwork.hostNetwork }}
securityContext:
fsGroup: {{ .Values.gluetunID.group }}
containers:
gluetun:
enabled: true
primary: true
imageSelector: image
securityContext:
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
capabilities:
add:
- NET_ADMIN
fixedEnv:
PUID: {{ .Values.gluetunID.user }}
envFrom:
- configMapRef:
name: gluetun
{{ with .Values.gluetunConfig.additionalEnvs }}
envList:
{{ range $env := . }}
- name: {{ $env.name }}
value: {{ $env.value }}
{{ end }}
{{ end }}
probes:
liveness:
enabled: true
type: exec
command:
- /gluetun-entrypoint
- healthcheck
readiness:
enabled: true
type: exec
command:
- /gluetun-entrypoint
- healthcheck
startup:
enabled: true
type: exec
command:
- /gluetun-entrypoint
- healthcheck
{{/* Service */}}
{{/* Persistence */}}
persistence:
devtun:
enabled: true
type: device
hostPath: /dev/net/tun
targetSelector:
gluetun:
gluetun:
mountPath: /dev/net/tun
data:
enabled: true
type: {{ .Values.gluetunStorage.data.type }}
datasetName: {{ .Values.gluetunStorage.data.datasetName | default "" }}
hostPath: {{ .Values.gluetunStorage.data.hostPath | default "" }}
targetSelector:
gluetun:
gluetun:
mountPath: /gluetun
{{- end -}}
@@ -0,0 +1,12 @@
{{- define "gluetun.validation" -}}
{{- $providers := (list "custom" "airvpn") -}}
{{- if not (mustHas .Values.gluetunConfig.provider $providers) -}}
{{- fail (printf "Gluetun - Expected [Provider] to be one of [%v], but got [%v]" (join ", " $providers) .Values.gluetunConfig.provider) -}}
{{- end -}}
{{- $types := (list "openvpn" "wireguard") -}}
{{- if not (mustHas .Values.gluetunConfig.type $types) -}}
{{- fail (printf "Gluetun - Expected [Type] to be one of [%v], but got [%v]" (join ", " $providers) .Values.gluetunConfig.type) -}}
{{- end -}}
{{- end -}}
@@ -0,0 +1,7 @@
{{- include "ix.v1.common.loader.init" . -}}
{{/* Merge the templates with Values */}}
{{- $_ := mustMergeOverwrite .Values (include "gluetun.configuration" $ | fromYaml) -}}
{{- $_ := mustMergeOverwrite .Values (include "gluetun.workload" $ | fromYaml) -}}
{{- include "ix.v1.common.loader.apply" . -}}
@@ -0,0 +1,14 @@
{{- define "gluetun.configs.common.env" -}}
{{- with .Values.gluetunConfig.serverCountries }}
SERVER_COUNTRIES: {{ join "," }}
{{- end }}
{{- with .Values.gluetunConfig.serverRegions }}
SERVER_REGIONS: {{ join "," }}
{{- end }}
{{- with .Values.gluetunConfig.serverCities }}
SERVER_CITIES: {{ join "," }}
{{- end }}
{{- with .Values.gluetunConfig.serverHostnames }}
SERVER_HOSTNAMES: {{ join "," }}
{{- end }}
{{- end -}}
@@ -0,0 +1,8 @@
{{- define "gluetun.configs.openvpn.env" -}}
{{- with .Values.gluetunConfig.openvpnKey }}
OPENVPN_KEY: {{ . }}
{{- end }}
{{- with .Values.gluetunConfig.openvpnCert }}
OPENVPN_CERT: {{ . }}
{{- end }}
{{- end -}}
@@ -0,0 +1,18 @@
{{- define "gluetun.airvpn.openvpn.env" -}}
{{- include "gluetun.configs.openvpn.env" $ -}}
{{- end -}}
{{- define "gluetun.airvpn.wireguard.env" -}}
{{- if not .Values.gluetunConfig.wireguardPrivateKey -}}
{{- fail "Gluetun - Expected non empty [Wireguard Private Key] on [AirVPN] provider and [Wireguard] Type" -}}
{{- end -}}
{{- if not .Values.gluetunConfig.wireguardPresharedKey -}}
{{- fail "Gluetun - Expected non empty [Wireguard Preshared Key] on [AirVPN] provider and [Wireguard] Type" -}}
{{- end -}}
{{- if not .Values.gluetunConfig.wireguardAddresses -}}
{{- fail "Gluetun - Expected non empty [Wireguard Addresses] on [AirVPN] provider and [Wireguard] Type" -}}
{{- end }}
WIREGUARD_PRIVATE_KEY: {{ .Values.gluetunConfig.wireguardPrivateKey }}
WIREGUARD_PRESHARED_KEY: {{ .Values.gluetunConfig.wireguardPresharedKey }}
WIREGUARD_ADDRESSES: {{ join "," .Values.gluetunConfig.wireguardAddresses }}
{{- end -}}
@@ -0,0 +1,51 @@
image:
repository: qmcgaw/gluetun
pullPolicy: IfNotPresent
tag: v3.33.0
resources:
limits:
cpu: 4000m
memory: 8Gi
gluetunNetwork:
hostNetwork: false
gluetunID:
user: 568
group: 568
gluetunStorage:
data:
type: ixVolume
hostPath: ''
datasetName: data
gluetunConfig:
provider: ''
type: ''
openvpnUser: ''
openvpnPassword: ''
# - Common Wireguard options
wireguardPrivateKey: ''
wireguardPresharedKey: ''
wireguardAddresses: []
# - Common OpenVPN options
# Optional - Alternative place the file in the data dir
# https://github.com/qdm12/gluetun/wiki/OpenVPN-client-key
openvpnKey: ''
# Optional - Alternative place the file in the data dir
# https://github.com/qdm12/gluetun/wiki/OpenVPN-client-key
openvpnCert: ''
# - Common options (Optional)
# https://raw.githubusercontent.com/qdm12/gluetun/master/internal/storage/servers.json
serverCountries: []
serverRegions: []
serverCities: []
serverHostnames: []
serverNames: []
additionalEnvs: []