enhancement: add support for http to https redirect for traefik gatew… (#1712)

This commit is contained in:
majinghe
2026-02-04 20:21:42 +08:00
committed by GitHub
parent 7a42af922d
commit e30781654d
5 changed files with 43 additions and 7 deletions
@@ -5,19 +5,25 @@ metadata:
name: {{ include "rustfs.fullname" . }}-gateway
spec:
gatewayClassName: {{ .Values.gatewayApi.gatewayClass }}
{{- with .Values.gatewayApi.listeners }}
listeners:
{{- if .web }}
- name: http
port: 80
port: {{ .web.port }}
protocol: HTTP
allowedRoutes:
namespaces:
from: Same
{{- end }}
{{- if .websecure }}
- name: https
port: 443
port: {{ .websecure.port }}
protocol: HTTPS
tls:
mode: Terminate
certificateRefs:
- name: {{ .Values.ingress.tls.secretName }}
- name: {{ include "rustfs.fullname" $ }}-tls
kind: Secret
{{- end }}
{{- end }}
{{- end }}
@@ -10,8 +10,10 @@ spec:
{{- if .Values.gatewayApi.existingGateway.namespace }}
namespace: {{ .Values.gatewayApi.existingGateway.namespace }}
{{- end }}
sectionName: https
{{- else }}
- name: {{ include "rustfs.fullname" . }}-gateway
sectionName: https
{{- end }}
hostnames:
- {{ .Values.gatewayApi.hostname }}
@@ -25,4 +27,28 @@ spec:
port: {{ .Values.service.console.port }}
kind: TraefikService
group: traefik.io
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {{ include "rustfs.fullname" . }}-redirect
spec:
parentRefs:
{{- if .Values.gatewayApi.existingGateway.name }}
- name: {{ .Values.gatewayApi.existingGateway.name }}
{{- if .Values.gatewayApi.existingGateway.namespace }}
namespace: {{ .Values.gatewayApi.existingGateway.namespace }}
{{- end }}
sectionName: http
{{- else }}
- name: {{ include "rustfs.fullname" . }}-gateway
sectionName: http
{{- end }}
rules:
- filters:
- type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301
{{- end }}
@@ -14,6 +14,6 @@ spec:
cookie:
name: rustfs
httpOnly: true
secure: true
sameSite: none
secure: {{ .Values.ingress.tls.enabled | default false }}
sameSite: {{ if .Values.ingress.tls.enabled }}none{{ else }}lax{{ end }}
{{- end }}
+1 -2
View File
@@ -1,5 +1,4 @@
{{- if .Values.ingress.enabled -}}
{{- $secretName := .Values.ingress.tls.secretName }}
{{- $ingressAnnotations := dict }}
{{- if eq .Values.ingress.className "nginx" }}
{{- $ingressAnnotations = .Values.ingress.nginxAnnotations }}
@@ -29,7 +28,7 @@ spec:
{{- range .Values.ingress.hosts }}
- {{ .host | quote }}
{{- end }}
secretName: {{ $secretName }}
secretName: {{ include "rustfs.fullname" $ }}-tls
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
+5
View File
@@ -150,6 +150,11 @@ ingress:
gatewayApi:
enabled: false
gatewayClass: traefik
listeners: # Specify which listeners to create on the Gateway. Only support for traefik gatewayClass at the moment.
web:
port: 8000
websecure:
port: 8443
hostname: example.rustfs.com
existingGateway:
name: ""