Add support to Ingress for generation based on Dendrite config.

Signed-off-by: Omar Pakker <Omar007@users.noreply.github.com>
This commit is contained in:
Omar Pakker 2023-05-04 23:37:19 +02:00
parent 038ad8fea4
commit b263b79ee3
2 changed files with 83 additions and 22 deletions

View file

@ -1,24 +1,25 @@
{{- if .Values.ingress.enabled -}} {{- if .Values.ingress.enabled -}}
{{- $fullName := include "dendrite.fullname" . -}} {{- $fullName := include "dendrite.fullname" . -}}
{{- $svcPort := .Values.service.port -}} {{- $serverNameHost := .Values.dendrite_config.global.server_name -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- $wellKnownServerHost := default $serverNameHost (regexFind "^[^:]+" .Values.dendrite_config.global.well_known_server_name) -}}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} {{- $wellKnownClientHost := default $serverNameHost (regexFind "^[^:]+" .Values.dendrite_config.global.well_known_client_name) -}}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} {{- $allHosts := list $serverNameHost $wellKnownServerHost $wellKnownClientHost | uniq -}}
{{- end }} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1 apiVersion: networking.k8s.io/v1beta1
{{- else -}} {{- else -}}
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
{{- end }} {{- end }}
kind: Ingress kind: Ingress
metadata: metadata:
name: {{ $fullName }} name: {{ $fullName }}
labels: labels:
{{- include "dendrite.labels" . | nindent 4 }} {{- include "dendrite.labels" . | nindent 4 }}
annotations: annotations:
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
kubernetes.io/ingress.class: {{ .Values.ingress.className }}
{{- end }}
{{- with .Values.ingress.annotations }} {{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
@ -26,7 +27,7 @@ spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }} ingressClassName: {{ .Values.ingress.className }}
{{- end }} {{- end }}
{{- if .Values.ingress.tls }} {{- if kindIs "slice" .Values.ingress.tls }}
tls: tls:
{{- range .Values.ingress.tls }} {{- range .Values.ingress.tls }}
- hosts: - hosts:
@ -35,8 +36,16 @@ spec:
{{- end }} {{- end }}
secretName: {{ .secretName }} secretName: {{ .secretName }}
{{- end }} {{- end }}
{{- else if .Values.ingress.tls.generate }}
tls:
- hosts:
{{- range $allHosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ $fullName }}-ingress-tls
{{- end }} {{- end }}
rules: rules:
{{- if .Values.ingress.hostName }}
- host: {{ .Values.ingress.hostName | quote }} - host: {{ .Values.ingress.hostName | quote }}
http: http:
paths: paths:
@ -47,9 +56,60 @@ spec:
service: service:
name: {{ $fullName }} name: {{ $fullName }}
port: port:
number: {{ $svcPort }} name: http
{{- else }} {{- else }}
serviceName: {{ $fullName }} serviceName: {{ $fullName }}
servicePort: {{ $svcPort }} servicePort: http
{{- end }} {{- end }}
{{- end }} {{- else }}
- host: {{ $serverNameHost | quote }}
http:
paths:
- path: /.well-known/matrix
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
name: http
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
- host: {{ $wellKnownServerHost | quote }}
http:
paths:
{{- range list "/_matrix/key" "/_matrix/federation" }}
- path: {{ . | quote }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
name: http
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
- host: {{ $wellKnownClientHost | quote }}
http:
paths:
{{- range list "/_matrix/client" "/_matrix/media" }}
- path: {{ . | quote }}
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
name: http
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -19,7 +19,6 @@ signing_key:
resources: resources:
requests: requests:
memory: "512Mi" memory: "512Mi"
limits: limits:
memory: "4096Mi" memory: "4096Mi"
@ -60,7 +59,6 @@ extraVolumes: []
# secret: # secret:
# secretName: extra-config # secretName: extra-config
# -- Configure additional mount points volumes in the Dendrite Pod # -- Configure additional mount points volumes in the Dendrite Pod
extraVolumeMounts: [] extraVolumeMounts: []
# ex. # ex.
@ -222,7 +220,6 @@ dendrite_config:
# - msc2836 (Threading, see https://github.com/matrix-org/matrix-doc/pull/2836) # - msc2836 (Threading, see https://github.com/matrix-org/matrix-doc/pull/2836)
# - msc2946 (Spaces Summary, see https://github.com/matrix-org/matrix-doc/pull/2946) # - msc2946 (Spaces Summary, see https://github.com/matrix-org/matrix-doc/pull/2946)
app_service_api: app_service_api:
# -- Disable the validation of TLS certificates of appservices. This is # -- Disable the validation of TLS certificates of appservices. This is
# not recommended in production since it may allow appservice traffic # not recommended in production since it may allow appservice traffic
@ -369,14 +366,18 @@ postgresql:
enabled: false enabled: false
ingress: ingress:
# -- Create an ingress for a monolith deployment # -- Create an ingress for the deployment
enabled: false enabled: false
hosts: [] # -- The ingressClass to use. Will be converted to annotation if not yet supported.
className: "" className: ""
hostName: ""
# -- Extra, custom annotations # -- Extra, custom annotations
annotations: {} annotations: {}
# -- The ingress hostname for your matrix server.
# Should align with the server_name and well_known_* hosts.
# If not set, generated from the dendrite_config values.
hostName: ""
# -- TLS configuration. Should contain information for the server_name and well-known hosts.
# Alternatively, set tls.generate=true to generate defaults based on the dendrite_config.
tls: [] tls: []
service: service: