From 5b8e8b91e39ee845def81dbe246bcbd137ed8378 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 26 Jan 2024 01:38:29 -0500 Subject: [PATCH] fix: ensure all k3s traefik middleware resources are scoped to the process While we currently only create the middleware for the web process, scoping it by process will allow us to expand this in the future. --- .../templates/chart/https-redirect-middleware.yaml | 9 +++++++-- plugins/scheduler-k3s/templates/chart/ingress-route.yaml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/scheduler-k3s/templates/chart/https-redirect-middleware.yaml b/plugins/scheduler-k3s/templates/chart/https-redirect-middleware.yaml index 4365c713c..a1092ee92 100644 --- a/plugins/scheduler-k3s/templates/chart/https-redirect-middleware.yaml +++ b/plugins/scheduler-k3s/templates/chart/https-redirect-middleware.yaml @@ -1,3 +1,6 @@ +{{- $processName := "PROCESS_NAME" }} +{{- $config := .Values.processes.PROCESS_NAME }} +{{- if $config.web.domains }} --- apiVersion: traefik.io/v1alpha1 kind: Middleware @@ -5,11 +8,13 @@ metadata: annotations: dokku.com/managed: "true" labels: - app.kubernetes.io/instance: {{ $.Values.global.app_name }}-redirect-to-https + app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}-redirect-to-https + app.kubernetes.io/name: {{ $processName }} app.kubernetes.io/part-of: {{ $.Values.global.app_name }} - name: {{ $.Values.global.app_name}}-redirect-to-https + name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https namespace: {{ $.Values.global.namespace }} spec: redirectScheme: scheme: https permanent: true +{{- end }} diff --git a/plugins/scheduler-k3s/templates/chart/ingress-route.yaml b/plugins/scheduler-k3s/templates/chart/ingress-route.yaml index c4ccce5c9..4b4c14ba4 100644 --- a/plugins/scheduler-k3s/templates/chart/ingress-route.yaml +++ b/plugins/scheduler-k3s/templates/chart/ingress-route.yaml @@ -27,7 +27,7 @@ spec: match: Host(`{{ $domain }}`) {{- if and $config.web.tls.enabled (and (eq $port_map.scheme "http") $port_map.redirect_to_https) }} middlewares: - - name: {{ $.Values.global.app_name}}-redirect-to-https + - name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https namespace: {{ $.Values.global.namespace }} {{- end }} services: