Compare commits

..
2 Commits
Author SHA1 Message Date
Sebi 87ab065e24 Merge pull request 'feat(helm): redirect plain HTTP to HTTPS on the ingresses' (#154) from feat/helm-https-redirect into main
ci / test (push) Successful in 16m57s
release / release (push) Successful in 16m55s
ci / lint (push) Successful in 8m9s
ci / build (push) Successful in 16m27s
ci / image (push) Successful in 5m2s
2026-11-25 18:52:46 +00:00
Sebastian UnterschützandClaude Opus 5.5 25829671a5 feat(helm): redirect plain HTTP to HTTPS on the ingresses
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 12m11s
ci / lint (pull_request) Successful in 11m42s
ci / build (pull_request) Successful in 16m4s
ci / image (pull_request) Successful in 3m19s
With TLS on, the console's and the status pages' ingresses now send HTTP to
HTTPS: through a redirectScheme middleware the chart creates for Traefik,
which is chained before any middlewares already annotated, and by
annotation for ingress-nginx and HAProxy. ingress.tls.redirect and
statuspage.ingress.tls.redirect turn it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-25 19:43:37 +01:00
4 changed files with 63 additions and 4 deletions

No files matched your search

@@ -170,3 +170,53 @@ $secret being the chart secret to read values from.
medium: Memory medium: Memory
sizeLimit: 64Mi sizeLimit: 64Mi
{{- end -}} {{- end -}}
{{/*
HTTPS redirect of an ingress: include with (dict "root" . "ingress" <values>
"name" <ingress name>). Traefik needs a redirectScheme middleware, other
controllers an annotation. */}}
{{- define "uptimesebi.redirects" -}}
{{- $i := .ingress -}}
{{- if and $i.tls.enabled $i.tls.redirect }}true{{ end -}}
{{- end -}}
{{- define "uptimesebi.traefik" -}}
{{- $i := .ingress -}}
{{- if contains "traefik" ($i.className | default "") -}}true
{{- else if and (not $i.className) (.root.Capabilities.APIVersions.Has "traefik.io/v1alpha1/Middleware") -}}true
{{- end -}}
{{- end -}}
{{/* the ingress's annotations, with those the redirect needs. */}}
{{- define "uptimesebi.ingressAnnotations" -}}
{{- $a := deepCopy (.ingress.annotations | default dict) -}}
{{- if include "uptimesebi.redirects" . -}}
{{- if include "uptimesebi.traefik" . -}}
{{- $key := "traefik.ingress.kubernetes.io/router.middlewares" -}}
{{- $mw := printf "%s-%s-https@kubernetescrd" .root.Release.Namespace .name -}}
{{- with get $a $key }}{{ $mw = printf "%s,%s" $mw . }}{{ end -}}
{{- $_ := set $a $key $mw -}}
{{- else -}}
{{- $_ := set $a "nginx.ingress.kubernetes.io/ssl-redirect" "true" -}}
{{- $_ := set $a "haproxy.org/ssl-redirect" "true" -}}
{{- end -}}
{{- end -}}
{{- with $a }}{{ toYaml . }}{{ end -}}
{{- end -}}
{{/* the Traefik middleware the redirect uses, if it needs one. */}}
{{- define "uptimesebi.redirectMiddleware" -}}
{{- if and (include "uptimesebi.redirects" .) (include "uptimesebi.traefik" .) }}
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: {{ .name }}-https
labels:
{{- include "uptimesebi.labels" .root | nindent 4 }}
spec:
redirectScheme:
scheme: https
permanent: true
{{- end }}
{{- end -}}
@@ -1,13 +1,14 @@
{{- if .Values.ingress.enabled }} {{- if .Values.ingress.enabled }}
{{- $ing := dict "root" . "ingress" .Values.ingress "name" (include "uptimesebi.fullname" .) }}
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: {{ include "uptimesebi.fullname" . }} name: {{ include "uptimesebi.fullname" . }}
labels: labels:
{{- include "uptimesebi.labels" . | nindent 4 }} {{- include "uptimesebi.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }} {{- with include "uptimesebi.ingressAnnotations" $ing }}
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- with .Values.ingress.className }} {{- with .Values.ingress.className }}
@@ -29,4 +30,5 @@ spec:
name: {{ include "uptimesebi.fullname" . }}-api name: {{ include "uptimesebi.fullname" . }}-api
port: port:
name: http name: http
{{- include "uptimesebi.redirectMiddleware" $ing }}
{{- end }} {{- end }}
@@ -118,6 +118,7 @@ spec:
{{- include "uptimesebi.selector" (list . "statuspage") | nindent 6 }} {{- include "uptimesebi.selector" (list . "statuspage") | nindent 6 }}
{{- end }} {{- end }}
{{- if .Values.statuspage.ingress.enabled }} {{- if .Values.statuspage.ingress.enabled }}
{{- $ing := dict "root" . "ingress" .Values.statuspage.ingress "name" $name }}
--- ---
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
@@ -125,9 +126,9 @@ metadata:
name: {{ $name }} name: {{ $name }}
labels: labels:
{{- include "uptimesebi.labels" . | nindent 4 }} {{- include "uptimesebi.labels" . | nindent 4 }}
{{- with .Values.statuspage.ingress.annotations }} {{- with include "uptimesebi.ingressAnnotations" $ing }}
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- with .Values.statuspage.ingress.className }} {{- with .Values.statuspage.ingress.className }}
@@ -152,5 +153,6 @@ spec:
port: port:
name: http name: http
{{- end }} {{- end }}
{{- include "uptimesebi.redirectMiddleware" $ing }}
{{- end }} {{- end }}
{{- end }} {{- end }}
+5
View File
@@ -144,6 +144,9 @@ ingress:
enabled: false enabled: false
# Secret with the certificate, e.g. made by cert-manager. # Secret with the certificate, e.g. made by cert-manager.
secretName: "" secretName: ""
# Send plain HTTP to HTTPS: through a redirectScheme middleware with
# Traefik, by annotation with ingress-nginx and HAProxy.
redirect: true
# -- Checker -- # -- Checker --
# A checker in the cluster, for checks from the cluster's region. Create # A checker in the cluster, for checks from the cluster's region. Create
@@ -197,6 +200,8 @@ statuspage:
tls: tls:
enabled: false enabled: false
secretName: "" secretName: ""
# Send plain HTTP to HTTPS, as for the console.
redirect: true
resources: resources:
requests: requests:
cpu: 50m cpu: 50m