From bcd8f0555dc1c054a5215c157f68c09e0506a5bb Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Wed, 22 Dec 2021 15:30:58 +0100 Subject: [PATCH] feat(traefik): allow port-based redirect and move redirect to advanced settings. (#1601) Also moves port in the gui and removes setting targetPort by default --- charts/core/traefik/questions.yaml | 56 ++++++++++++++++--------- charts/core/traefik/templates/_args.tpl | 5 +++ charts/core/traefik/values.yaml | 2 + 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/charts/core/traefik/questions.yaml b/charts/core/traefik/questions.yaml index d9b9ac02ef9..8c81d5ae4f6 100644 --- a/charts/core/traefik/questions.yaml +++ b/charts/core/traefik/questions.yaml @@ -584,6 +584,12 @@ questions: schema: type: dict attrs: + - variable: port + label: "Entrypoints Port" + schema: + type: int + default: 9080 + required: true - variable: advanced label: "Show Advanced settings" schema: @@ -617,23 +623,26 @@ questions: description: "The internal(!) port on the container the Application runs on" schema: type: int - default: 9080 - - variable: port - label: "Entrypoints Port" - schema: - type: int - default: 9080 - required: true - - variable: redirectTo - label: "Redirect to" - schema: - type: string - default: "websecure" + - variable: redirectPort + label: "Redirect to Port" + schema: + type: int + - variable: redirectTo + label: "Redirect to Entrypoint" + schema: + type: string + default: "websecure" - variable: websecure label: "websecure Entrypoints Configuration" schema: type: dict attrs: + - variable: port + label: "Entrypoints Port" + schema: + type: int + default: 9443 + required: true - variable: advanced label: "Show Advanced settings" schema: @@ -667,13 +676,14 @@ questions: description: "The internal(!) port on the container the Application runs on" schema: type: int - default: 9443 - - variable: port - label: "Entrypoints Port" - schema: - type: int - default: 9443 - required: true + - variable: redirectPort + label: "Redirect to Port" + schema: + type: int + - variable: redirectTo + label: "Redirect to Entrypoint" + schema: + type: string - variable: tls label: "websecure Entrypoints Configuration" schema: @@ -736,6 +746,14 @@ questions: schema: type: boolean default: true + - variable: redirectPort + label: "Redirect to Port" + schema: + type: int + - variable: redirectTo + label: "Redirect to Entrypoint" + schema: + type: string - variable: metrics label: "metrics Service" description: "The metrics Entrypoint service" diff --git a/charts/core/traefik/templates/_args.tpl b/charts/core/traefik/templates/_args.tpl index 41e7e44b8fd..e3a069a06d7 100644 --- a/charts/core/traefik/templates/_args.tpl +++ b/charts/core/traefik/templates/_args.tpl @@ -68,6 +68,11 @@ args: {{- $toPort := index $ports $config.redirectTo }} - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.to=:{{ $toPort.port }}" - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.scheme=https" + {{- else if $config.redirectPort }} + {{ if gt $config.redirectPort 0.0 }} + - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.to=:{{ $config.redirectPort }}" + - "--entrypoints.{{ $entrypoint }}.http.redirections.entryPoint.scheme=https" + {{- end }} {{- end }} {{- if or ( $config.tls ) ( eq $config.protocol "HTTPS" ) }} {{- if or ( $config.tls.enabled ) ( eq $config.protocol "HTTPS" ) }} diff --git a/charts/core/traefik/values.yaml b/charts/core/traefik/values.yaml index bce4dd7b848..3981fe9e0ac 100644 --- a/charts/core/traefik/values.yaml +++ b/charts/core/traefik/values.yaml @@ -150,6 +150,8 @@ service: port: 9080 protocol: HTTP redirectTo: websecure + # Options: Empty, 0 (ingore), or positive int + # redirectPort: websecure: enabled: true port: 9443