From 37eec10d2b252aab0a4f8fd1560b394eca254889 Mon Sep 17 00:00:00 2001 From: tectux Date: Sun, 6 Oct 2024 21:26:41 +0000 Subject: [PATCH] Merge wellknown, use nginx conf.d, improvements --- conduit/templates/ingress.yaml | 9 +++ conduit/templates/wellknown/configmap.yaml | 10 ++- conduit/templates/wellknown/deployment.yaml | 14 ++-- conduit/templates/wellknown/service.yaml | 2 +- .../templates/wellknowncustom/configmap.yaml | 11 --- .../templates/wellknowncustom/deployment.yaml | 79 ------------------- .../templates/wellknowncustom/service.yaml | 18 ----- conduit/values.yaml | 45 +++-------- 8 files changed, 33 insertions(+), 155 deletions(-) delete mode 100644 conduit/templates/wellknowncustom/configmap.yaml delete mode 100644 conduit/templates/wellknowncustom/deployment.yaml delete mode 100644 conduit/templates/wellknowncustom/service.yaml diff --git a/conduit/templates/ingress.yaml b/conduit/templates/ingress.yaml index 1962e8b..851dbf3 100644 --- a/conduit/templates/ingress.yaml +++ b/conduit/templates/ingress.yaml @@ -76,5 +76,14 @@ spec: name: {{ include "conduit.fullname" . }}-wellknown port: name: http + {{- if .Values.wellknown.rewriteRoot }} + - path: / + pathType: Exact + backend: + service: + name: {{ include "conduit.fullname" . }}-wellknown + port: + name: http + {{- end }} {{- end }} {{- end }} diff --git a/conduit/templates/wellknown/configmap.yaml b/conduit/templates/wellknown/configmap.yaml index 868c59c..93d96e4 100644 --- a/conduit/templates/wellknown/configmap.yaml +++ b/conduit/templates/wellknown/configmap.yaml @@ -2,10 +2,12 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "conduit.fullname" . }}-wellknown + name: {{ include "conduit.fullname" . }}-nginx-wellknown labels: {{- include "conduit.labels" . | nindent 4 }} data: - server: {{ toJson .Values.wellknown.server | quote }} - client: {{ toJson .Values.wellknown.client | quote }} -{{- end }} \ No newline at end of file + default.conf: | + {{- with .Values.wellknown}} + {{ tpl .nginxServerConf . | quote | indent 4 }} + {{- end }} +{{- end }} diff --git a/conduit/templates/wellknown/deployment.yaml b/conduit/templates/wellknown/deployment.yaml index eded4fc..8da7d5f 100644 --- a/conduit/templates/wellknown/deployment.yaml +++ b/conduit/templates/wellknown/deployment.yaml @@ -46,17 +46,19 @@ spec: protocol: TCP livenessProbe: httpGet: - path: / + path: /nginx_health port: http readinessProbe: httpGet: - path: / + path: /nginx_health port: http resources: {{- toYaml .Values.wellknown.resources | nindent 12 }} volumeMounts: - - name: "data" - mountPath: "/usr/share/nginx/html/.well-known/matrix/" + - name: "wellknown-nginx-conf" + mountPath: "/etc/nginx/conf.d/default.conf" + subPath: default.conf + readOnly: true {{- with .Values.wellknown.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -70,7 +72,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: "data" + - name: "wellknown-nginx-conf" configMap: - name: {{ include "conduit.fullname" . }}-wellknown + name: {{ include "conduit.fullname" . }}-nginx-wellknown {{- end }} diff --git a/conduit/templates/wellknown/service.yaml b/conduit/templates/wellknown/service.yaml index 929e068..780e068 100644 --- a/conduit/templates/wellknown/service.yaml +++ b/conduit/templates/wellknown/service.yaml @@ -15,4 +15,4 @@ spec: selector: {{- include "conduit.selectorLabels" . | nindent 4 }} type: wellknown -{{- end }} \ No newline at end of file +{{- end }} diff --git a/conduit/templates/wellknowncustom/configmap.yaml b/conduit/templates/wellknowncustom/configmap.yaml deleted file mode 100644 index 7173d37..0000000 --- a/conduit/templates/wellknowncustom/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -{{- if .Values.wellknowncustom.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "conduit.fullname" . }}-nginx-wellknowncustom - labels: - {{- include "conduit.labels" . | nindent 4 }} -data: - nginx.conf: | - {{ .Values.wellknowncustom.nginx_conf | nindent 4 }} -{{- end }} \ No newline at end of file diff --git a/conduit/templates/wellknowncustom/deployment.yaml b/conduit/templates/wellknowncustom/deployment.yaml deleted file mode 100644 index c3bc297..0000000 --- a/conduit/templates/wellknowncustom/deployment.yaml +++ /dev/null @@ -1,79 +0,0 @@ -{{- if .Values.wellknowncustom.enabled }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "conduit.fullname" . }}-wellknowncustom - labels: - {{- include "conduit.labels" . | nindent 4 }} - app.kubernetes.io/component: wellknowncustom -spec: - replicas: {{ .Values.wellknowncustom.replicaCount }} - selector: - matchLabels: - {{- include "conduit.selectorLabels" . | nindent 6 }} - app.kubernetes.io/component: wellknowncustom - template: - metadata: - {{- with .Values.wellknowncustom.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "conduit.selectorLabels" . | nindent 8 }} - app.kubernetes.io/component: wellknowncustom - {{- with .Values.wellknowncustom.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - type: wellknowncustom - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "conduit.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.wellknowncustom.podSecurityContext | nindent 8 }} - containers: - - name: wellknowncustom - securityContext: - {{- toYaml .Values.wellknowncustom.securityContext | nindent 12 }} - {{- with .Values.wellknowncustom.image }} - image: "{{ .registry }}/{{ .repository }}:{{ .tag }}" - {{- end }} - imagePullPolicy: {{ .Values.wellknowncustom.image.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.wellknowncustom.containerPort }} - protocol: TCP - livenessProbe: - httpGet: - path: /nginx_health - port: http - readinessProbe: - httpGet: - path: /nginx_health - port: http - resources: - {{- toYaml .Values.wellknowncustom.resources | nindent 12 }} - volumeMounts: - - name: "wellknowncustom-nginx-conf" - mountPath: "/etc/nginx/nginx.conf" - subPath: nginx.conf - readOnly: true - {{- with .Values.wellknowncustom.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.wellknowncustom.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.wellknowncustom.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - volumes: - - name: "wellknowncustom-nginx-conf" - configMap: - name: {{ include "conduit.fullname" . }}-nginx-wellknowncustom -{{- end }} diff --git a/conduit/templates/wellknowncustom/service.yaml b/conduit/templates/wellknowncustom/service.yaml deleted file mode 100644 index c8583cc..0000000 --- a/conduit/templates/wellknowncustom/service.yaml +++ /dev/null @@ -1,18 +0,0 @@ -{{- if .Values.wellknowncustom.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "conduit.fullname" . }}-wellknowncustom - labels: - {{- include "conduit.labels" . | nindent 4 }} -spec: - type: {{ .Values.wellknowncustom.service.type }} - ports: - - port: {{ .Values.wellknowncustom.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "conduit.selectorLabels" . | nindent 4 }} - type: wellknowncustom -{{- end }} \ No newline at end of file diff --git a/conduit/values.yaml b/conduit/values.yaml index 8e2545e..5a3f947 100644 --- a/conduit/values.yaml +++ b/conduit/values.yaml @@ -67,6 +67,9 @@ wellknown: port: 8080 annotations: {} + # if ingress is enabled: specifies whether ingress should redirect the `/`-Location to the wellknown server + rewriteRoot: true + # TO EDIT: server: "m.server": "your.server.name:443" @@ -76,55 +79,26 @@ wellknown: "org.matrix.msc3575.proxy": "url": "https://your.server.name/" -wellknowncustom: - enabled: false - image: - registry: docker.io - repository: library/nginx - pullPolicy: IfNotPresent - tag: "1.27.1" - - replicaCount: 1 - podLabels: {} - podAnnotations: [] - podSecurityContext: {} - securityContext: {} - containerPort: 8080 - env: [] - resources: {} - nodeSelector: {} - tolerations: [] - affinity: {} - - service: - type: ClusterIP - port: 8080 - annotations: {} - - # TO EDIT: - nginx_conf: | - user nginx; - worker_processes 1; - events { - worker_connections 10240; - } - http { + # EDIT IF NEEDED + nginxServerConf: |- server { listen 8080; server_name localhost; location /.well-known/matrix/server { - return 200 '{"m.server": "your.server.name:443"}'; + return 200 {{ toJson .server | quote }}; types { } default_type "application/json; charset=utf-8"; } location /.well-known/matrix/client { - return 200 '{"m.homeserver": {"base_url": "https://your.server.name/"}, "org.matrix.msc3575.proxy": {"url": "https://your.server.name/"}}'; + return 200 {{ toJson .client | quote }}; types { } default_type "application/json; charset=utf-8"; add_header "Access-Control-Allow-Origin" *; } location / { + # return 200 'Welcome to the your.server.name conduit server!'; + # types { } default_type "text/plain; charset=utf-8"; return 404; } @@ -133,7 +107,6 @@ wellknowncustom: types { } default_type "text/plain; charset=utf-8"; } } - } podLabels: {} podAnnotations: {}