diff --git a/library/ix-dev/community/gluetun/Chart.lock b/library/ix-dev/community/gluetun/Chart.lock new file mode 100644 index 0000000000..e6736e3cc4 --- /dev/null +++ b/library/ix-dev/community/gluetun/Chart.lock @@ -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" diff --git a/library/ix-dev/community/gluetun/charts/common-1.0.7.tgz b/library/ix-dev/community/gluetun/charts/common-1.0.7.tgz new file mode 100644 index 0000000000..d691d5af09 Binary files /dev/null and b/library/ix-dev/community/gluetun/charts/common-1.0.7.tgz differ diff --git a/library/ix-dev/community/gluetun/ci/airvpn-openvpn-values.yaml b/library/ix-dev/community/gluetun/ci/airvpn-openvpn-values.yaml new file mode 100644 index 0000000000..4a06713a27 --- /dev/null +++ b/library/ix-dev/community/gluetun/ci/airvpn-openvpn-values.yaml @@ -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' diff --git a/library/ix-dev/community/gluetun/questions.yaml b/library/ix-dev/community/gluetun/questions.yaml new file mode 100644 index 0000000000..7d0bfd2156 --- /dev/null +++ b/library/ix-dev/community/gluetun/questions.yaml @@ -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.
+ 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 diff --git a/library/ix-dev/community/gluetun/templates/NOTES.txt b/library/ix-dev/community/gluetun/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/gluetun/templates/_configuration.tpl b/library/ix-dev/community/gluetun/templates/_configuration.tpl new file mode 100644 index 0000000000..5d74e1f878 --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/_configuration.tpl @@ -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 -}} diff --git a/library/ix-dev/community/gluetun/templates/_gluetun.tpl b/library/ix-dev/community/gluetun/templates/_gluetun.tpl new file mode 100644 index 0000000000..4f54e162ae --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/_gluetun.tpl @@ -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 -}} diff --git a/library/ix-dev/community/gluetun/templates/_validation.tpl b/library/ix-dev/community/gluetun/templates/_validation.tpl new file mode 100644 index 0000000000..a5cab31688 --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/_validation.tpl @@ -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 -}} diff --git a/library/ix-dev/community/gluetun/templates/common.yaml b/library/ix-dev/community/gluetun/templates/common.yaml new file mode 100644 index 0000000000..a20c02f538 --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/common.yaml @@ -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" . -}} diff --git a/library/ix-dev/community/gluetun/templates/configs/_common.tpl b/library/ix-dev/community/gluetun/templates/configs/_common.tpl new file mode 100644 index 0000000000..de5b8ae5fd --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/configs/_common.tpl @@ -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 -}} diff --git a/library/ix-dev/community/gluetun/templates/configs/_openvpn.tpl b/library/ix-dev/community/gluetun/templates/configs/_openvpn.tpl new file mode 100644 index 0000000000..d84241c5c5 --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/configs/_openvpn.tpl @@ -0,0 +1,8 @@ +{{- define "gluetun.configs.openvpn.env" -}} + {{- with .Values.gluetunConfig.openvpnKey }} +OPENVPN_KEY: {{ . }} + {{- end }} + {{- with .Values.gluetunConfig.openvpnCert }} +OPENVPN_CERT: {{ . }} + {{- end }} +{{- end -}} diff --git a/library/ix-dev/community/gluetun/templates/providers/airvpn.tpl b/library/ix-dev/community/gluetun/templates/providers/airvpn.tpl new file mode 100644 index 0000000000..ad159be25e --- /dev/null +++ b/library/ix-dev/community/gluetun/templates/providers/airvpn.tpl @@ -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 -}} diff --git a/library/ix-dev/community/gluetun/values.yaml b/library/ix-dev/community/gluetun/values.yaml new file mode 100644 index 0000000000..1879294fe3 --- /dev/null +++ b/library/ix-dev/community/gluetun/values.yaml @@ -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: []