Merge pull request 'feat(helm): redirect plain HTTP to HTTPS on the ingresses' (#154) from feat/helm-https-redirect into main
This commit was merged in pull request #154.
This commit is contained in:
commit
87ab065e24
4 files changed
+63
-4
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 }}
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in new issue
Block a user