diff --git a/chart/templates/httproute.yaml b/chart/templates/httproute.yaml new file mode 100644 index 0000000..9ac113d --- /dev/null +++ b/chart/templates/httproute.yaml @@ -0,0 +1,98 @@ +{{- if .Values.httpRoute.enabled -}} +{{- $fullName := include "fusionauth.fullname" . -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "fusionauth.name" . }} + helm.sh/chart: {{ include "fusionauth.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.httpRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- range .Values.httpRoute.parentRefs }} + - name: {{ .name }} + {{- with .namespace }} + namespace: {{ . }} + {{- end }} + sectionName: https + {{- end }} + {{- with .Values.httpRoute.hostnames }} + hostnames: + {{- toYaml . | nindent 4 }} + {{- end }} + rules: + - matches: + {{- range .Values.httpRoute.matches }} + - path: + type: {{ .path.type | default "PathPrefix" }} + value: {{ .path.value | default "/" }} + {{- with .method }} + method: {{ . }} + {{- end }} + {{- with .headers }} + headers: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .queryParams }} + queryParams: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- end }} + {{- with .Values.httpRoute.filters }} + filters: + {{- toYaml . | nindent 8 }} + {{- end }} + backendRefs: + - name: {{ $fullName }} + port: {{ .Values.service.port }} + {{- with .Values.httpRoute.backendRefs.weight }} + weight: {{ . }} + {{- end }} +{{- if .Values.httpRoute.redirect }} +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }}-redirect + labels: + app.kubernetes.io/name: {{ include "fusionauth.name" . }} + helm.sh/chart: {{ include "fusionauth.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.httpRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- range .Values.httpRoute.parentRefs }} + - name: {{ .name }} + {{- with .namespace }} + namespace: {{ . }} + {{- end }} + sectionName: http + {{- end }} + {{- with .Values.httpRoute.hostnames }} + hostnames: + {{- toYaml . | nindent 4 }} + {{- end }} + rules: + - matches: + {{- range .Values.httpRoute.matches }} + - path: + type: {{ .path.type | default "PathPrefix" }} + value: {{ .path.value | default "/" }} + {{- end }} + filters: + - type: RequestRedirect + requestRedirect: + scheme: https + statusCode: 301 +{{- end }} +{{- end }} diff --git a/chart/values.schema.json b/chart/values.schema.json index fbc4e13..b82aa5e 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -137,6 +137,35 @@ } } }, + "httpRoute": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "annotations": { + "type": "object" + }, + "parentRefs": { + "type": "array" + }, + "hostnames": { + "type": "array" + }, + "matches": { + "type": "array" + }, + "filters": { + "type": "array" + }, + "backendRefs": { + "type": "object" + }, + "redirect": { + "type": "boolean" + } + } + }, "initContainers": { "type": "object", "properties": { diff --git a/chart/values.yaml b/chart/values.yaml index 1367767..e709731 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -208,6 +208,38 @@ ingress: # hosts: # - chart-example.local + httpRoute: + # httpRoute.enabled -- Enables HTTPRoute creation for fusionauth (requires Gateway API) + enabled: false + # httpRoute.annotations -- Configure annotations to add to the HTTPRoute object + annotations: {} + # httpRoute.parentRefs -- List of parent Gateway references + parentRefs: + - name: gateway + namespace: default + # Optional: specify a specific listener section + # sectionName: https + # httpRoute.hostnames -- List of hostnames for the route + hostnames: + - fusionauth.example.com + # httpRoute.matches -- Path matching rules for the route + matches: + - path: + type: PathPrefix + value: / + # httpRoute.filters -- Optional filters to apply to requests + filters: [] + # - type: RequestHeaderModifier + # requestHeaderModifier: + # set: + # - name: X-Custom-Header + # value: custom-value + # httpRoute.backendRefs -- Backend configuration + backendRefs: + weight: 1 + # httpRoute.redirect -- Enable HTTP to HTTPS redirect HTTPRoute (creates a separate HTTPRoute for redirection) + redirect: false + # resources -- Define resource requests and limits for fusionauth-app. resources: {} # We usually recommend not to specify default resources and to leave this as a conscious