common: fix gluetun and add test (#37090)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->

⚒️ Fixes  #36999
⚒️ Fixes #36770

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [x] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code
- [ ] 📜 Documentation Changes

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made changes to the documentation
- [x] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [x] ⬆️ I increased versions for any altered app according to semantic
versioning
- [x] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):`, `chore(chart-name):`, `docs(chart-name):` or
`fix(docs):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Signed-off-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com>
Co-authored-by: Alfred Göppel <43101280+alfi0812@users.noreply.github.com>
This commit is contained in:
Stavros Kois
2025-07-07 15:42:44 +03:00
committed by GitHub
parent e8594b4b21
commit 931df7567e
4 changed files with 55 additions and 17 deletions
@@ -10,6 +10,7 @@ tests:
resources:
limits:
nvidia.com/gpu: 1
addons:
gluetun:
enabled: true
@@ -26,6 +27,9 @@ tests:
key1: value1
key2: value2
key3: value3
FIREWALL: "on"
FIREWALL_OUTBOUND_SUBNETS: "10.0.0/8, 192.168.0/16"
FIREWALL_INPUT_PORTS: "8080 , 8443"
workload: &workload
main:
enabled: true
@@ -44,6 +48,15 @@ tests:
startup:
enabled: false
service:
main:
enabled: true
primary: false
ports:
main:
enabled: true
primary: true
protocol: http
port: 8089
service-name1:
enabled: true
primary: true
@@ -54,14 +67,14 @@ tests:
port: 8080
asserts:
- hasDocuments:
count: 3
count: 4
- documentIndex: &SecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: &ServiceDocument 2
- documentIndex: &ServiceDocument 3
isKind:
of: Service
- documentIndex: *SecretDocument
@@ -157,6 +170,18 @@ tests:
content:
name: key3
value: value3
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].env
content:
name: FIREWALL_OUTBOUND_SUBNETS
value: 10.0.0/8,192.168.0/16,172.16.0.0/16,172.17.0.0/16
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].env
content:
name: FIREWALL_INPUT_PORTS
value: 8080,8443,8089
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
+1 -1
View File
@@ -48,4 +48,4 @@ sources:
- https://hub.docker.com/_/
- https://hub.docker.com/r/mikefarah/yq
type: library
version: 28.12.6
version: 28.12.7
@@ -11,24 +11,27 @@ It will include / inject the required templates based on the given values.
{{- $fw := $glue.container.env.FIREWALL -}}
{{- if (eq $fw "on") -}}
{{- $nets := list -}}
{{- if and (hasKey $glue.container.env "FIREWALL_OUTBOUND_SUBNETS") (ne $glue.container.env.FIREWALL_OUTBOUND_SUBNETS "") -}}
{{- $nets = splitList "," $glue.container.env.FIREWALL_OUTBOUND_SUBNETS -}}
{{- end -}}
{{- $nets := $glue.container.env.FIREWALL_OUTBOUND_SUBNETS | default list -}}
{{- if $nets -}}{{- $nets = $nets | splitList "," -}}{{- end -}}
{{- $nets = mustAppend $nets $.Values.chartContext.podCIDR -}}
{{- $nets = mustAppend $nets $.Values.chartContext.svcCIDR -}}
{{- $nets = mustUniq $nets -}}
{{- $cleanNets := list -}}
{{- range $nets -}}{{- $cleanNets = mustAppend $cleanNets (. | nospace) -}}{{- end -}}
{{- $nets = $cleanNets | mustUniq -}}
{{- $_ := set $glue.container.env "FIREWALL_OUTBOUND_SUBNETS" (join "," $nets) -}}
{{- $inputPorts := list -}}
{{- if hasKey $glue.container.env "FIREWALL_INPUT_PORTS" -}}
{{- $inputPorts = splitList "," $glue.container.env.FIREWALL_INPUT_PORTS -}}
{{- $inputPorts := $glue.container.env.FIREWALL_INPUT_PORTS | default list -}}
{{- if $inputPorts -}}{{- $inputPorts = $inputPorts | splitList "," -}}{{- end -}}
{{- if and
$.Values.service $.Values.service.main $.Values.service.main.ports
$.Values.service.main.ports.main $.Values.service.main.ports.main.port
-}}
{{- $inputPorts = mustAppend $inputPorts ($.Values.service.main.ports.main.port | toString) -}}
{{- end -}}
{{- if and $.Values.service $.Values.service.main $.Values.service.main.ports $.Values.service.main.ports.main $.Values.service.main.ports.main.port -}}
{{- $inputPorts = mustAppend $inputPorts $.Values.service.main.ports.main.port -}}
{{- end -}}
{{- $inputPorts = $inputPorts | mustUniq -}}
{{- $cleanInputPorts := list -}}
{{- range $inputPorts -}}{{- $cleanInputPorts = mustAppend $cleanInputPorts (. | nospace) -}}{{- end -}}
{{- $inputPorts = $cleanInputPorts | mustUniq -}}
{{- $_ := set $glue.container.env "FIREWALL_INPUT_PORTS" (join "," $inputPorts) -}}
{{- end -}}
@@ -52,7 +55,9 @@ It will include / inject the required templates based on the given values.
{{- $_ := set $secValues "enabled" true -}}
{{- $_ := set $.Values.secret $secretName $secValues -}}
{{- $persistence := (dict "enabled" true "type" "secret" "objectName" $secretName "targetSelector" dict "items" list ) -}}
{{- $persistence := (dict
"enabled" true "type" "secret" "objectName" $secretName "targetSelector" dict "items" list
) -}}
{{- if $secValues.defaultMode -}}
{{- $_ := set $persistence "defaultMode" $secValues.defaultMode -}}
{{- end -}}
@@ -33,6 +33,14 @@
{{- $podCIDR := "172.16.0.0/16" -}}
{{- $svcCIDR := "172.17.0.0/16" -}}
{{- if $rootCtx.Values.global.podCIDR -}}
{{- $podCIDR = $rootCtx.Values.global.podCIDR -}}
{{- end -}}
{{- if $rootCtx.Values.global.svcCIDR -}}
{{- $svcCIDR = $rootCtx.Values.global.svcCIDR -}}
{{- end -}}
{{/* TODO: Find ways to implement CIDR detection */}}
{{/* If there is ingress, get data from the primary */}}