feat(traefik): add some middlewares (#11058)

**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 #4999
⚒️ Fixes #5633

**⚙️ 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
- [ ] 👀 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
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 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._

---------

Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Signed-off-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Co-authored-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
This commit is contained in:
Stavros Kois 2023-07-31 12:16:47 +03:00 committed by GitHub
parent 77d8b810b3
commit 5ac7e22f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 126 additions and 1 deletions

View File

@ -23,7 +23,7 @@ sources:
- https://github.com/traefik/traefik-helm-chart
- https://traefik.io/
type: application
version: 19.0.4
version: 19.1.0
annotations:
truecharts.org/catagories: |
- network

View File

@ -184,8 +184,10 @@ questions:
attrs:
# Include{basicAuthMiddleware}
# Include{forwardAuthMiddleware}
# Include{bufferingMiddleware}
# Include{customRequestHeadersMiddleware}
# Include{customResponseHeadersMiddleware}
# Include{customFrameOptionsValueMiddleware}
# Include{chainMiddleware}
# Include{redirectSchemeMiddleware}
# Include{rateLimitMiddleware}

View File

@ -0,0 +1,26 @@
{{- range $index, $middlewareData := .Values.middlewares.buffering }}
---
# Declaring the user list
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }}
namespace: tc-system
spec:
buffering: {{/* Only render if its not <nil> and has a value of 0 or greater */}}
{{- if not (kindIs "invalid" $middlewareData.maxRequestBodyBytes) (ge ($middlewareData.maxRequestBodyBytes | int) 0) }}
maxRequestBodyBytes: {{ $middlewareData.maxRequestBodyBytes }}
{{- end -}}
{{- if not (kindIs "invalid" $middlewareData.memRequestBodyBytes) (ge ($middlewareData.memRequestBodyBytes | int) 0) }}
memRequestBodyBytes: {{ $middlewareData.memRequestBodyBytes }}
{{- end -}}
{{- if not (kindIs "invalid" $middlewareData.maxResponseBodyBytes) (ge ($middlewareData.maxResponseBodyBytes | int) 0) }}
maxResponseBodyBytes: {{ $middlewareData.maxResponseBodyBytes }}
{{- end -}}
{{- if not (kindIs "invalid" $middlewareData.memResponseBodyBytes) (ge ($middlewareData.memResponseBodyBytes | int) 0) }}
memResponseBodyBytes: {{ $middlewareData.memResponseBodyBytes }}
{{- end -}}
{{- if $middlewareData.retryExpression }}
retryExpression: {{ $middlewareData.retryExpression | quote }}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,12 @@
{{- range $index, $middlewareData := .Values.middlewares.customFrameOptionsValue }}
---
# Declaring the user list
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: {{ ternary (printf "%v-%v" $.Release.Name $middlewareData.name) $middlewareData.name $.Values.ingressClass.enabled }}
namespace: tc-system
spec:
headers:
customFrameOptionsValue: {{ $middlewareData.value }}
{{- end -}}

View File

@ -346,6 +346,16 @@ middlewares:
# value: "foobar"
# - name: X-Header-To-Remove
# value: ""
customFrameOptionsValue: []
# - name: customFrameOptionsValueExample
# value: "SAMEORIGIN"
buffering: []
# - name: bufferingExample
# maxRequestBodyBytes: 1000000
# memRequestBodyBytes: 1000000
# maxResponseBodyBytes: 1000000
# memResponseBodyBytes: 1000000
# retryExpression: "IsNetworkError() && Attempts() < 2"
chain: []
# - name: chainname
# middlewares:

View File

@ -0,0 +1,51 @@
- variable: buffering
label: Buffering
schema:
type: list
default: []
items:
- variable: bufferingEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: maxRequestBodyBytes
label: Max Request Body Bytes
description: Leave empty and it won't be set
schema:
type: string
valid_chars: '^[0-9]*$'
default: ""
- variable: memRequestBodyBytes
label: Mem Request Body Bytes
description: Leave empty and it won't be set
schema:
type: string
valid_chars: '^[0-9]*$'
default: ""
- variable: maxResponseBodyBytes
label: Max Response Body Bytes
description: Leave empty and it won't be set
schema:
type: string
valid_chars: '^[0-9]*$'
default: ""
- variable: memResponseBodyBytes
label: Mem Response Body Bytes
description: Leave empty and it won't be set
schema:
type: string
valid_chars: '^[0-9]*$'
default: ""
- variable: retryExpression
label: Retry Expression
description: Leave empty and it won't be set
schema:
type: string
default: ""

View File

@ -0,0 +1,24 @@
- variable: customFrameOptionsValue
label: Custom Frame Options Value
schema:
type: list
default: []
items:
- variable: customFrameOptionsValueEntry
label: ""
schema:
additional_attrs: true
type: dict
attrs:
- variable: name
label: Name
schema:
type: string
required: true
- variable: value
label: X-Frame-Options Header Value
description: The value of the header.
schema:
type: string
required: true
default: ""