feat: enable forceTLS on traefik integration on main ingress by default (#667)

**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  # <!--(issue)-->

**⚙️ Type of change**

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

**🧪 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 corresponding changes to the documentation
- [x] ⚠️ My changes generate no new warnings
- [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

** App addition**

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

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ 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._

---------

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
This commit is contained in:
Kjeld Schouten
2023-12-28 14:50:16 +01:00
committed by GitHub
parent a98174eaed
commit 6bc7e087fc
5 changed files with 83 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ appVersion: ""
dependencies:
- name: common
repository: file://../common
version: ~17.1.0
version: ~17.2.0
deprecated: false
description: Helper chart to test different use cases of the common library
home: https://github.com/truecharts/apps/tree/master/charts/library/common-test

View File

@@ -46,6 +46,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd
- documentIndex: *ingressDoc
@@ -113,6 +114,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-tc-opencors-chain@kubernetescrd
@@ -149,6 +151,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-tc-opencors-chain@kubernetescrd
@@ -180,6 +183,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-some-fixed-middleware@kubernetescrd
@@ -211,6 +215,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd
@@ -237,6 +242,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
- it: should not contain fixed middlewares when local is disabled
@@ -263,6 +269,7 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
- it: should add the defined middlewares to the ingress
@@ -298,9 +305,79 @@ tests:
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd,test-release-namespace-some-middleware@kubernetescrd,test-release-namespace-some-other-middleware@kubernetescrd
- it: should add the the tls annotation
set:
operator: *operator
service: *service
global: *global
ingress:
my-ingress:
enabled: true
primary: true
integrations:
traefik:
enabled: true
forceTLS: true
entrypoints:
- web
hosts: *hosts
asserts:
- documentIndex: *ingressDoc
isKind:
of: Ingress
- documentIndex: *ingressDoc
isKind:
of: Ingress
- documentIndex: *ingressDoc
equal:
path: metadata.name
value: test-release-name-common-test
- documentIndex: *ingressDoc
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd
- it: should not add the the tls annotation
set:
operator: *operator
service: *service
global: *global
ingress:
my-ingress:
enabled: true
primary: true
integrations:
traefik:
enabled: true
forceTLS: false
entrypoints:
- web
hosts: *hosts
asserts:
- documentIndex: *ingressDoc
isKind:
of: Ingress
- documentIndex: *ingressDoc
isKind:
of: Ingress
- documentIndex: *ingressDoc
equal:
path: metadata.name
value: test-release-name-common-test
- documentIndex: *ingressDoc
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: test-release-namespace-chain-basic@kubernetescrd
# Failures
- it: should fail with entrypoint not a slice
set:

View File

@@ -15,4 +15,4 @@ maintainers:
name: common
sources: null
type: library
version: 17.1.5
version: 17.2.0

View File

@@ -119,8 +119,8 @@
{{- $_ := set $objectData.annotations "traefik.ingress.kubernetes.io/router.middlewares" (join "," $formattedMiddlewares) -}}
{{- end -}}
{{- if or $traefik.forceTLS ( has websecure $entrypoints ) -}}
{{- $_ := set $objectData.annotations "traefik.ingress.kubernetes.io/router.tls" 'true' -}}
{{- if or $traefik.forceTLS (mustHas "websecure" $entrypoints) -}}
{{- $_ := set $objectData.annotations "traefik.ingress.kubernetes.io/router.tls" "true" -}}
{{- end -}}
{{- end -}}

View File

@@ -593,6 +593,8 @@ ingress:
entrypoints:
- websecure
enableFixedMiddlewares: true
# Ensures tls annotation is set
forceTLS: true
# Drops both global and local fixedMiddlewares when enabled
allowCors: false
# fixedMiddlewares: