From 75d4cc4cb1ec483b4dd3eab68da4ba02c8fbd27d Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Mon, 15 Apr 2024 18:54:37 +0200 Subject: [PATCH 1/2] fix: use pathType ImplementationSpecific for regex fix error ``` path /(/?|$)(.*) cannot be used with pathType Prefix ``` Signed-off-by: Guilhem Lettron --- charts/devlake/templates/ingresses.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/charts/devlake/templates/ingresses.yaml b/charts/devlake/templates/ingresses.yaml index 72b08aa..99bd54a 100644 --- a/charts/devlake/templates/ingresses.yaml +++ b/charts/devlake/templates/ingresses.yaml @@ -63,8 +63,12 @@ spec: - path: /{{ include "devlake.grafanaEndpointPrefix" . }} {{- end }} {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + {{- if .Values.ingress.useDefaultNginx }} + pathType: ImplementationSpecific + {{- else }} pathType: Prefix {{- end }} + {{- end }} backend: {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} service: @@ -82,8 +86,12 @@ spec: - path: /{{ include "devlake.uiEndpointPrefix" . }} {{- end}} {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + {{- if .Values.ingress.useDefaultNginx }} + pathType: ImplementationSpecific + {{- else }} pathType: Prefix {{- end }} + {{- end }} backend: {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} service: @@ -133,7 +141,7 @@ spec: paths: - path: /{{ include "devlake.grafanaEndpointPrefix" . }}(/|$)(.*) {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} - pathType: Prefix + pathType: ImplementationSpecific {{- end }} backend: # dummy to config-ui, actual 302 forearding for external grafana {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} From 9c7f1d00875411da0fc45aab98b6e754a7cd6a54 Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Wed, 24 Apr 2024 15:10:25 +0200 Subject: [PATCH 2/2] chore: split grafana and root specifix ingress This simplify template and overriding. --- charts/devlake/templates/ingresses.yaml | 65 ++++++++----------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/charts/devlake/templates/ingresses.yaml b/charts/devlake/templates/ingresses.yaml index 99bd54a..cab10bf 100644 --- a/charts/devlake/templates/ingresses.yaml +++ b/charts/devlake/templates/ingresses.yaml @@ -36,9 +36,6 @@ metadata: labels: {{- include "devlake.labels" . | nindent 4 }} annotations: - {{- if .Values.ingress.useDefaultNginx }} - nginx.ingress.kubernetes.io/rewrite-target: /$2 - {{- end}} {{- with .Values.ingress.annotations }} {{- toYaml . | nindent 4 }} {{- end }} @@ -56,42 +53,10 @@ spec: - host: {{ .Values.ingress.hostname | quote }} http: paths: - {{- if .Values.grafana.enabled }} - {{- if .Values.ingress.useDefaultNginx }} - - path: /{{ include "devlake.grafanaEndpointPrefix" . }}(/|$)(.*) - {{- else }} - - path: /{{ include "devlake.grafanaEndpointPrefix" . }} - {{- end }} - {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} - {{- if .Values.ingress.useDefaultNginx }} - pathType: ImplementationSpecific - {{- else }} - pathType: Prefix - {{- end }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ .Values.grafana.ingressServiceName | default ( include "grafana.fullname" (dict "Values" .Values.grafana "Chart" (dict "Name" "grafana") "Release" .Release ) ) }} - port: - number: {{ .Values.grafana.ingressServicePort | default .Values.grafana.service.port }} - {{- else }} - serviceName: {{ .Values.grafana.ingressServiceName | default ( include "grafana.fullname" (dict "Values" .Values.grafana "Chart" (dict "Name" "grafana") "Release" .Release ) ) }} - servicePort: {{ .Values.grafana.ingressServicePort | default .Values.grafana.service.port }} - {{- end }} - {{- end }} - {{- if .Values.ingress.useDefaultNginx }} - - path: /{{ include "devlake.uiEndpointPrefix" . }}(/?|$)(.*) - {{- else }} - path: /{{ include "devlake.uiEndpointPrefix" . }} - {{- end}} {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} - {{- if .Values.ingress.useDefaultNginx }} - pathType: ImplementationSpecific - {{- else }} pathType: Prefix {{- end }} - {{- end }} backend: {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} service: @@ -105,7 +70,6 @@ spec: {{- if .Values.ingress.extraPaths }} {{- toYaml .Values.ingress.extraPaths | nindent 10 }} {{- end }} -{{- if and .Values.ingress.useDefaultNginx (not .Values.grafana.enabled) }} --- {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1 @@ -116,12 +80,17 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: - name: {{ $fullName }}-ext-grafana + name: {{ $fullName }}-grafana labels: {{- include "devlake.labels" . | nindent 4 }} annotations: + {{- if .Values.ingress.useDefaultNginx }} + nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/rewrite-target: /$2 + {{- end}} + {{- if not .Values.ingress.enabled }} nginx.ingress.kubernetes.io/permanent-redirect: {{ .Values.grafana.external.url }} + {{- end }} {{- with .Values.ingress.annotations }} {{- toYaml . | nindent 4 }} {{- end }} @@ -139,19 +108,27 @@ spec: - host: {{ .Values.ingress.hostname | quote }} http: paths: + {{- if .Values.ingress.useDefaultNginx }} - path: /{{ include "devlake.grafanaEndpointPrefix" . }}(/|$)(.*) + {{- else }} + - path: /{{ include "devlake.grafanaEndpointPrefix" . }} + {{- end }} {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + {{- if .Values.ingress.useDefaultNginx }} pathType: ImplementationSpecific + {{- else }} + pathType: Prefix {{- end }} - backend: # dummy to config-ui, actual 302 forearding for external grafana + {{- end }} + # dummy in case of external grafana (redirect 308) + backend: {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} service: - name: {{ $uiServiceName }} + name: {{ .Values.grafana.ingressServiceName | default ( include "grafana.fullname" (dict "Values" .Values.grafana "Chart" (dict "Name" "grafana") "Release" .Release ) ) }} port: - number: 4000 + number: {{ .Values.grafana.ingressServicePort | default .Values.grafana.service.port }} {{- else }} - serviceName: {{ $uiServiceName }} - servicePort: 4000 + serviceName: {{ .Values.grafana.ingressServiceName | default ( include "grafana.fullname" (dict "Values" .Values.grafana "Chart" (dict "Name" "grafana") "Release" .Release ) ) }} + servicePort: {{ .Values.grafana.ingressServicePort | default .Values.grafana.service.port }} {{- end }} -{{- end }} -{{- end }} +{{- end -}}